Adding a custom Sequence to all Dialogues

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
bladderbloat
Posts: 2
Joined: Mon Apr 22, 2024 9:00 am

Adding a custom Sequence to all Dialogues

Post 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();
                }
            }
        }
    }
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding a custom Sequence to all Dialogues

Post 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);
bladderbloat
Posts: 2
Joined: Mon Apr 22, 2024 9:00 am

Re: Adding a custom Sequence to all Dialogues

Post 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!
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding a custom Sequence to all Dialogues

Post by Tony Li »

Glad to help!
Post Reply