DialogueManager having difficulty finding Actor on Start?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
2linescrossed
Posts: 47
Joined: Tue May 16, 2023 10:37 pm

DialogueManager having difficulty finding Actor on Start?

Post by 2linescrossed »

Hi, I'm currently working with DialogueActors in my current scene and I'm dealing with some issues with registration -
Specifically, I have a couple of 'fade in' animations that play when the characters' gameobjects are enabled, but due to the Dialogue Manager, this breaks some of the code I have that keeps track of specific characters' animators - basically, if I set the object active, despite it having the dialogactor component, the Manager is unable to find it, likely due to registration timing issues?
The sequencer works fine if the character is enabled at the start of loading into the scene (ie, for speaker or conversant checks), but not if I enable the character partway through, early in the conversation using the sequencer for a conversation.

Oddly, I also enable three other characters later in the same conversation, but they're completely functional when that happens. I figure this is likely an issue with the DialogueManager not registering the inactive object from the start of the scene?
Could you give me recommendations for how to resolve this problem within the Conversation/Sequencer itself, or is that something I have to solve externally?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: DialogueManager having difficulty finding Actor on Start?

Post by Tony Li »

Hi,

A GameObject with a DialogueActor component will register itself with the Dialogue System in Start().

When a conversation starts, it will immediately check this registry for the conversation's primary actor and conversant and cache those values.

If other characters are involved in the conversation, they will be looked up and cached the first time they speak a line.

Since your primary actor and conversant aren't active when the conversation starts, they're not cached at the start of the conversation. To resolve this, you can add a small script to them that adds their DialogueActor info to the active conversation's cache. That script's Start() method could look something like:

Code: Select all

void Start()
{
    if (DialogueManager.isConversationActive)
    {
        var dialogueActor = GetComponent<DialogueActor>();
        var actor = DialogueManager.masterDatabase.GetActor(dialogueActor.actor);
        DialogueManager.conversationModel.OverrideCharacterInfo(actor.id, this.transform);
    }
}
Post Reply