Page 1 of 3

Animate Characters While Speaking

Posted: Sun Feb 06, 2022 12:32 am
by PayasoPrince
Hello,

I was following the Cutscene sequence 3 video on animating characters while speaking and I added the following sequence to a gameobjects Dialogue System Trigger:

Code: Select all

AnimatorPlayWait(Talking)->Message(Done);
AnimatorPlay(Idle)@Message(Done)
It is set to play OnConversation start.
For some reason they're not animating when I start a conversation clip. :?

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 9:05 am
by Tony Li
Hi,

That sequence is probably something you should add to a conversation's dialogue entry node or the Default Sequence since it should play when nodes are shown.

Then check for any errors or warnings in the Console window.

You can also temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. This will log a lot of information to the Console window. Each sequencer command will log two lines.

The first line reports the result of parsing the command and scheduling a time for it to play. It will look something like:

Code: Select all

Dialogue System: Sequencer.Play( AnimatorPlayWait(Talking)@0 )
The second line will appear when the command actually executes. It will show which GameObject is it using for the Animator component. For example:

Code: Select all

Dialogue System: Sequencer: AnimatorPlayWait(Talking, SpeakerHere, 0, -1)
where SpeakerHere is the current node's speaker. Make sure the speaker is correct. Otherwise you will need to either specify the speaker in the commands or change which GameObject is used as the speaker (e.g., assigned to the Dialogue System Trigger's Conversation Actor or Conversation Conversant.)


Also, I recommend adding the 'required' keyword to the second command:

Code: Select all

AnimatorPlayWait(Talking)->Message(Done);
required AnimatorPlay(Idle)@Message(Done)
This will guarantee that it plays Idle even if the player skips ahead before AnimatorPlayWait() has finished.


If Talking is a short animation (for example, just one loop of opening and closing the mouth), you may want it to loop for the duration of {{end}} instead:

Code: Select all

AnimatorPlay(Talking);
required AnimatorPlay(Idle)@{{end}}

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 1:17 pm
by PayasoPrince
Thanks for the proactive advice!

Sure enough, I had the the wrong actor set on the dialogue node, ugh. :oops:

One thing I noticed is that the animation is only playing once. How can I make this loop? :?:

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 1:30 pm
by Tony Li
AnimatorPlayWait() will wait for it to play once. Then your AnimatorPlayWait() command will send the sequencer message "Done". While the actual animation that AnimatorPlayWait() plays could loop, the next command will receive the "Done" message and switch to the Idle animation.

If you wanted to loop for a duration, such as 3 seconds or the value of {{end}}, you could use the example I posted above that uses two AnimatorPlay() commands and @{{end}}. Make sure your animation clip's Loop checkbox is ticked.

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 2:37 pm
by PayasoPrince
Ack, completely missed that last part of the message. :oops:

Using just this line plays the animation.

Code: Select all

AnimatorPlay(Talking);
But when I add this line after it never happens :?

Code: Select all

required AnimatorPlay(Idle)@{{end}}

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 2:42 pm
by Tony Li
Any errors or warnings in the Console window?

The value of {{end}} is the higher of:
  • Dialogue Manager: Display Settings > Subtitle Settings > Min Subtitle Seconds, or
  • text length / Subtitle Chars Per Second
Is {{end}} high enough? If it ends up being a very low number such as 0.0 or 0.1, it will switch to Idle almost right away.

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 8:24 pm
by PayasoPrince
Hi Tony,

Hmm, I don't believe its the value of end being high enough since "min subtitle seconds" is 2.

I do have some warnings in the console though. Doesn't seem to recognize "{{end}}"
Image

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 9:30 pm
by Tony Li
Hi,

Does DemoScene1's conversation with the NPC play correctly without any errors in the Console?

It uses {{end}}, which should automatically be handled internally by the Dialogue System.

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 9:36 pm
by PayasoPrince
Yes, nothing logged to the console in DemoScene1 when I speak with the NPC.

Re: Animate Characters While Speaking

Posted: Sun Feb 06, 2022 9:51 pm
by Tony Li
Is this sequence used in a conversation? If it's in a conversation -- such as in a dialogue entry node's Sequence field or the Dialogue Manager's Default Sequence -- then the {{end}} tag should be handled properly.

If the sequence is being played outside of a conversation -- for example, in a Dialogue System Trigger's Actions > Play Sequence -- the {{end}} value is undefined since it's not associated with subtitle text, so you shouldn't use it there.