Sync Animation to Subtitle printing instead of dialogue end

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tougon
Posts: 7
Joined: Mon Sep 07, 2020 12:15 pm

Sync Animation to Subtitle printing instead of dialogue end

Post by Tougon »

Hello, I've been syncing character talk animations up in the sequence controls, but I've noticed there are some situations where the dialogue doesn't sync to the animation. This is because my current setup uses the end of the sequence to swap the player's animation. If the continue mode is false, this causes the dialogue to finish printing, but the talk animation still plays. In addition, the talk animation will play if I use the /. sequencer to delay text. Is it possible to sync the animations through the sequencer so they only play when subtitle text is printing? I'm using the default TMPro Typewriter effects to handle printing.

Thanks!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sync Animation to Subtitle printing instead of dialogue end

Post by Tony Li »

Hi,

Yes. The typewriter effect sends the sequencer message "Typed" when it's done. You can set the dialogue entry's Sequence (or the Dialogue Manager's Default Sequence) to something like:

Code: Select all

AnimatorPlay(talk);
required AnimatorPlay(idle)@Message(Typed)
AnimatorPlay(talk) will play as soon as the dialogue entry starts.

AnimatorPlay(idle) will play when the typewriter ends. The 'required' keyword guarantees that it plays even if the player skips ahead before the typewriter is done. Technically the typewriter will send "Typed" even if the player skips ahead, so this is just an extra safety measure.
User avatar
Tougon
Posts: 7
Joined: Mon Sep 07, 2020 12:15 pm

Re: Sync Animation to Subtitle printing instead of dialogue end

Post by Tougon »

Thank you for the response!

This is half of what I'm looking for. Now, dialogue stops when it's done printing. However, I would also like for the talking animation to stop playing if a pause in dialogue (\.) occurs. Right now, I have a node that begins with a pause, and the talk animation plays during the pause, before the character's dialogue begins printing. Is it possible to truly sync animations up to dialogue in this way such that if a pause occurs, they return to their idle until text begins printing again without hardcoding this behavior into each sequence that uses a pause?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sync Animation to Subtitle printing instead of dialogue end

Post by Tony Li »

Hi,

There's nothing built in to stop the talk animation during RPG Maker-style pause codes. With some scripting, you could make a subclass of TextMeshProTypewriterEffetct. Override the Play() coroutine. In the section of code that pauses, also handle animation:

Code: Select all

case RPGMakerTokenType.FullPause:
    // << YOUR CODE HERE TO STOP TALK ANIMATION >>
    yield return DialogueTime.WaitForSeconds(fullPauseDuration);
    // << YOUR CODE HERE TO RESUME TALK ANIMATION >>
    break;
Alternatively, if you're playing audio you could use SALSA or a lipsync asset to handle the talking animation. SALSA will move the character's mouth to approximate the sounds that are being played. If no sound is being played, the mouth will stay closed.
User avatar
Tougon
Posts: 7
Joined: Mon Sep 07, 2020 12:15 pm

Re: Sync Animation to Subtitle printing instead of dialogue end

Post by Tougon »

Finally got the chance to test this out and it's working great for my purposes, thanks for the help!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sync Animation to Subtitle printing instead of dialogue end

Post by Tony Li »

Glad to help!
Post Reply