Changing DialogueManager.CurrentConversant during dialogue

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
BoringSuburbanDad
Posts: 3
Joined: Mon Nov 04, 2024 3:31 pm

Changing DialogueManager.CurrentConversant during dialogue

Post by BoringSuburbanDad »

Hi there,

I use the variable "CurrentConversant" in some of my C# scripts.
However, when I change the conversant during a running dialogue, it doesn't seem to have an impact on the scripts. So I assume that CurrentConversant isn't updated while a dialogue is active.

Is there any way to change to change it manually?
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing DialogueManager.CurrentConversant during dialogue

Post by Tony Li »

Hi,

What's your intent? I may be able to provide a simpler solution.
BoringSuburbanDad
Posts: 3
Joined: Mon Nov 04, 2024 3:31 pm

Re: Changing DialogueManager.CurrentConversant during dialogue

Post by BoringSuburbanDad »

I have multiple scripts, working like this:

Code: Select all

    
    private void Update()
    {
        var conversant = DialogueManager.CurrentConversant;

        if (conversant != null)
        {
        something happens, depending on the CurrentConversant
        }  
    }
Everything works fine so far. But if I change the conversant in the Dialogue System during a dialogue at some point (via inspector), the scripts don't seem to update.

Thank you for looking into this!
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing DialogueManager.CurrentConversant during dialogue

Post by Tony Li »

Hi,

Checking something every frame is called polling, which generally isn't a very efficient approach.

You may want to consider events instead. For example, if you want to know which GameObjects are the speaker and listener of each dialogue entry in an active conversation, you can add a script (or multiple scripts) with an OnConversationLine(Subtitle) method. Example:

Code: Select all

void OnConversationLine(Subtitle)
{
    if (subtitle.speakerInfo.transform == this.transform)
    {
        // I'm the speaker, so do something special here.
        // ...
    }
}
Post Reply