Changing conversant based on variable before conversation starts.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
sanmaow
Posts: 6
Joined: Tue Jul 05, 2022 4:24 pm

Changing conversant based on variable before conversation starts.

Post by sanmaow »

Hi Tony,

My game has multiple characters the player can select from. Each character is a unique prefab and based on which one the player selected the selected character's index will be stored in a variable. I want each character to have a different set of portraits during dialogue. Currently I am going at this by setting a different actor for each character with different portraits, but I don't know how to get my characterIndex variable before a conversation and set the corresponding actor during runtime.
User avatar
Tony Li
Posts: 21959
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing conversant based on variable before conversation starts.

Post by Tony Li »

Hi,

How are you starting conversations?

Let's say you have a GameObject for each conversant. Each of these GameObjects has a Dialogue Actor component whose Actor dropdown points to the correct character.

If you're starting a conversation in C#, you can pass the GameObject to DialogueManager.StartConversation(), such as:

Code: Select all

GameObject conversant = CharacterIndexToConversant(characterIndex); // (Example)
DialogueManager.StartConversation("title", playerTransform, conversant.transform);
If you're starting the conversation from a Dialogue System Trigger, you can make a subclass of DialogueSystemTrigger. Example:

Code: Select all

protected override void DoConversationAction(Transform actor)
{
    conversationConversant = CharacterIndexToConversant(characterIndex).transform;
    base.DoConversaitonAction(actor);
}
Post Reply