Page 1 of 1

Animated Portrait - Default Sequence Value

Posted: Mon Jan 27, 2020 9:58 pm
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.

Re: Animated Portrait - Default Sequence Value

Posted: Mon Jan 27, 2020 10:06 pm
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?

Re: Animated Portrait - Default Sequence Value

Posted: Tue Jan 28, 2020 8:36 am
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;
    }
}

Re: Animated Portrait - Default Sequence Value

Posted: Tue Jan 28, 2020 1:58 pm
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!

Re: Animated Portrait - Default Sequence Value

Posted: Tue Jan 28, 2020 2:09 pm
by Tony Li
Awesome; glad I could help.