Page 1 of 1

Easiest way to change portrait name?

Posted: Wed Aug 05, 2020 10:35 am
by cro
I'm using a modified version of the JRPG template:

Image

I have a GameObject that I've named NPC and intend to use as a generic prefab. I have an npcName variable set in a script on that object as a string value.

I'd like to either use that npcName variable somehow via script or set the name that shows up in portrait name -- the "(Name)" text. As is it just uses the GameObject's name, so it always shows "NPC" as the speaker. I've tried using the DialogueActor and Usable's "Override Name" field, but to no avail. Is there something else I should be doing?

Re: Easiest way to change portrait name?

Posted: Wed Aug 05, 2020 10:46 am
by Tony Li
Hi,

If you assign the NPC GameObject to the Dialogue System Trigger's Start Conversation > Conversation Conversant field, and add a Dialogue Actor component to the NPC GameObject, then you should be able to set the DialogueActor.actor variable to the value of your npcName variable. Note that you must do this before starting the conversation. The conversation will cache the character's name as soon as the conversation starts so it doesn't have to continually look it up.

If you can't set it before starting the conversation, let me know. There are other options.

Re: Easiest way to change portrait name?

Posted: Wed Aug 05, 2020 11:32 am
by cro
Thanks, Tony!

I definitely overlooked some stuff when searching earlier ^^;;

For anyone else looking for a quick step-by-step:

Add the dialogue actor component to your gameobject

Image

Actually add the actor name in the dialogue system's actors tab

Image

It now appears in the dropdown

Image

And correctly changes the name!

Image

Re: Easiest way to change portrait name?

Posted: Wed Aug 05, 2020 1:02 pm
by Tony Li
Thanks for sharing!

Side note: If you're setting DialogueActor.actor from code, you should be able to assign any string to it. As long as that GameObject is assigned to the trigger's Conversation Conversant, it will use whatever string you assign to actor.

Extra tangent side note: You can include [var=variable] and [lua(code)] tags in the actor string (or the actor's Display Name in the Dialogue Editor for that matter). This is useful is actor names, or even parts of actor names, can change.

Re: Easiest way to change portrait name?

Posted: Wed Aug 05, 2020 2:00 pm
by cro
Side note: If you're setting DialogueActor.actor from code, you should be able to assign any string to it. As long as that GameObject is assigned to the trigger's Conversation Conversant, it will use whatever string you assign to actor.
Oh, cool! So something like

Code: Select all

DialogueActor myActor = GetComponent<DialogueActor>();
myActor.actor = "Roland Deschain";
would work, yeah?

Re: Easiest way to change portrait name?

Posted: Wed Aug 05, 2020 2:10 pm
by Tony Li
Yes. Or even this if you want to get over-elaborate:

Code: Select all

myActor.actor = "[var=MainNPCName]";
DialogueLua.SetVariable("MainNPCName", "Roland Deschain");

Re: Easiest way to change portrait name?

Posted: Wed Aug 05, 2020 2:12 pm
by cro
Nice! Thanks for the help, Tony! Hopefully these little examples help anyone else who stumbles upon this :D