Animate Characters While Speaking

Announcements, support questions, and discussion for the Dialogue System.
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Animate Characters While Speaking

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

Re: Animate Characters While Speaking

Post 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}}
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Animate Characters While Speaking

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

Re: Animate Characters While Speaking

Post 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.
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Animate Characters While Speaking

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

Re: Animate Characters While Speaking

Post 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.
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Animate Characters While Speaking

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

Re: Animate Characters While Speaking

Post 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.
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Animate Characters While Speaking

Post by PayasoPrince »

Yes, nothing logged to the console in DemoScene1 when I speak with the NPC.
User avatar
Tony Li
Posts: 22152
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animate Characters While Speaking

Post 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.
Post Reply