Page 1 of 1

Dynamic "Player" actor name

Posted: Fri Apr 22, 2022 7:15 am
by mroshaw
Hi again!

In my game, the player is able to select from male and female characters. The player controller is spawned when the scene loads, from one of two prefabs that I have configured with Dialog and Quest Machine components.

Is there a way to configure the "Player" actor name within each of my player prefabs, so that an appropriate name is used within dialogues, depending on which player controller prefab instance is spawned? I thought perhaps the Dialog Actor component would give me this, and while I can configure a unique portrait image for each character, I cannot configure a unique name.

Your thoughts as ever are greatly appreciated. Thank you!

Re: Dynamic "Player" actor name

Posted: Fri Apr 22, 2022 7:24 am
by Tony Li
Hi,

There are two ways to do this:

1. My preference: Set your Dialogue Actor to the Player actor. Set the Player actor's Display Name to the male or female version of the name. You can do this in C# code like this:

Code: Select all

DialogueLua.SetActorField("Player", "Display Name", "name goes here");
Or without scripting, for example using a Dialogue System Trigger that runs this Lua statement:

Code: Select all

Actor["Player"].Display_Name = "name goes here"

2. Or create two separate player actors (e.g., MalePlayer and FemalePlayer) and assign them to your male and female player prefabs. The catch with this one is that you'll need to either assign the player to Dialogue System Triggers' Conversation Actor fields, or rely on setting the trigger to OnUse and OnTriggerEnter and leave the Conversation Actor field blank so it will use the GameObject that interacted with the trigger. (More info)

Re: Dynamic "Player" actor name

Posted: Fri Apr 22, 2022 8:13 am
by mroshaw
Amazing, thank you Tony. The first option looks to be ideal for this!

Re: Dynamic "Player" actor name

Posted: Fri Apr 22, 2022 8:32 am
by mroshaw
And, of course, it works absolutely perfectly!

Image

Re: Dynamic "Player" actor name

Posted: Fri Apr 22, 2022 9:31 am
by Tony Li
Looks good!