Dynamic "Player" actor name

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Dynamic "Player" actor name

Post 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!
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dynamic "Player" actor name

Post 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)
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Re: Dynamic "Player" actor name

Post by mroshaw »

Amazing, thank you Tony. The first option looks to be ideal for this!
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Re: Dynamic "Player" actor name

Post by mroshaw »

And, of course, it works absolutely perfectly!

Image
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dynamic "Player" actor name

Post by Tony Li »

Looks good!
Post Reply