Animated Portrait - Default Sequence Value

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Animated Portrait - Default Sequence Value

Post by VoodooDetective »

I was trying to figure out how to implement this for all conversations as the default sequence:

Code: Select all

AnimatorPlay(Talking, PC Portrait Image);
AnimatorPlay(Idle, PC Portrait Image)@Message(Typed);
Delay({{end}});
But I have several different subtitles at this point. I can write a custom sequence that finds the currently active subtitle like this:

Code: Select all

            GameObject dialoguePanel = GameObject.Find("Dialogue Panel");
            foreach (Transform child in dialoguePanel.transform)
            {
                if (child.name.EndsWith("Subtitle Panel") && child.gameObject.activeSelf)
                {
                    animator = child.gameObject.GetComponentInChildren<Animator>();
                    break;
                }
            }
But I was wondering if there's a better way? I just want the default behavior to play the talking animation and then stop it after the text is done appearing.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Animated Portrait - Default Sequence Value

Post by VoodooDetective »

Perhaps a script that loads the current Portrait Image name into a variable in lua? Like Should I attach a Dialogue System Events to the Dialogue Manager and then have a custom script that listens for OnConversationLine, and updates lua at that point?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animated Portrait - Default Sequence Value

Post by Tony Li »

Hi,

If you want that to be the default sequence, you can set the Dialogue Manager's Camera & Cutscene Settings > Default Sequence.

Since you're referencing PC Portrait Image, I assume it's for the PC only. In this case, set the Default Player Sequence to:

Code: Select all

AnimatorPlay(Talking, PC Portrait Image);
AnimatorPlay(Idle, PC Portrait Image)@Message(Typed);
Delay({{end}});
And you'll probably want to set the regular Default Sequence to:

Code: Select all

AnimatorPlay(Talking, NPC Portrait Image);
AnimatorPlay(Idle, NPC Portrait Image)@Message(Typed);
Delay({{end}});
It will be used for NPCs.

You might want to make it:

Code: Select all

AnimatorPlay(Talking, PC Portrait Image);
required AnimatorPlay(Idle, PC Portrait Image)@Message(Typed);
Delay({{end}});
The 'required' keyword guarantees that it plays the Idle animation even if the player skips ahead before the typewriter has finished. Technically the typewriter should always send the 'Typed' message even if you skip ahead, but I'd just add it as a safeguard.

BTW, you can also override the Default Sequence & Default Player Sequence for a specific conversation. Inspect the conversation in the Dialogue Editor, click on blank canvas space to inspect the conversation's properties, and tick Override Display Settings.

If you want to modify sequences at runtime, you can add a script with an OnConversationLine method to the Dialogue Manager. For example:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speakerInfo.isNPC)
    {
        // Always play a Beep sound for NPC lines:
        subtitle.sequence = "Audio(Beep); " + subtitle.sequence;
    }
}
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Animated Portrait - Default Sequence Value

Post by VoodooDetective »

Oh that's fantastic! I was wondering why I got double events fired for OnConversationLine. So cool you can modify the sequence with a script.

Great! I think I'm all set! The main thing I missed was that you could have separate default sequences for PC and NPC. Thanks!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animated Portrait - Default Sequence Value

Post by Tony Li »

Awesome; glad I could help.
Post Reply