Page 1 of 1

Adding a custom Sequence to all Dialogues

Posted: Tue Apr 23, 2024 7:48 am
by bladderbloat
Hello!

Thanks for the amazing plugin!

I would like to add my own "lipsync" sequence to all dialogues that currently will only have an audioclip dragged to it.

Right now the sequence field only has an "AudioWait(audioclipname)".

Is there a way to give all dialogue nodes a custom sequence by default while keeping the AudioWait? As I understand, the Dialogue Managers default sequence only runs if there is no sequence added to a dialogue line.

This is the basic code for the lipsync that I want to be fired off at every dialogue line.

Code: Select all

    public class SequencerCommandLipsync : SequencerCommand
    {
        Animator animator;
        AudioSource _audio;
        bool Lipsyncing;

        public void Start()
        {
            animator = GetSubject("speaker").GetComponent<Animator>();
            _audio = animator.GetComponent<AudioSource>();
        }

        private void Update()
        {
            if(_audio.clip != null && _audio.isPlaying)
            {
                if(Lipsyncing == false)
                {
                    Lipsyncing = true;
                    animator.Play("Talk", 2);
                }
            }
            else
            {
                if(Lipsyncing)
                {
                    animator.Play("Stop", 2);
                    Stop();
                }
            }
        }
    }

Re: Adding a custom Sequence to all Dialogues

Posted: Tue Apr 23, 2024 8:21 am
by Tony Li
Hi,

The other way to play the Dialogue Manager's Default Sequence is to also add the special keyword {{default}} to your dialogue entry's Sequence. Example:

Code: Select all

{{default}};
AudioWait(audioclipname)
If you set the Dialogue Manager's Default Sequence to "Lipsync()", the dialogue entry's actual sequence at runtime will be:

Code: Select all

Lipsync();
AudioWait(audioclipname)
A few notes:

You might want to move AudioWait(audioclipname) to the Default Sequence and use entrytags. This way you don't have to drag audio files into each entry's Sequence field. (The Cutscene Sequences Tutorial videos cover entrytags, too.)

You might not also need the Lipsync() command. You could set the Default Sequence to something like:

Code: Select all

AudioWait(entrytag)->Message(DoneSpeaking);
AnimatorPlay(Talk,,2);
required AnimatorPlay(Stop,,2)@Message(DoneSpeaking);

Re: Adding a custom Sequence to all Dialogues

Posted: Wed Apr 24, 2024 3:18 am
by bladderbloat
Nice! Entrytags will do just fine, thanks for that!

Might add to Lipsync a couple of parameters to animate the speaking character, like Lipsync(Mood, Talkanimation), and that would be unique for each line, so I guess that would have to be set for each sequence manually, but still save time with the entrytags and voice overs!

Re: Adding a custom Sequence to all Dialogues

Posted: Wed Apr 24, 2024 7:58 am
by Tony Li
Glad to help!