Page 1 of 1

Sync Animation to Subtitle printing instead of dialogue end

Posted: Fri Feb 26, 2021 9:38 am
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!

Re: Sync Animation to Subtitle printing instead of dialogue end

Posted: Fri Feb 26, 2021 10:47 am
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.

Re: Sync Animation to Subtitle printing instead of dialogue end

Posted: Fri Feb 26, 2021 4:15 pm
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?

Re: Sync Animation to Subtitle printing instead of dialogue end

Posted: Fri Feb 26, 2021 4:40 pm
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.

Re: Sync Animation to Subtitle printing instead of dialogue end

Posted: Tue Mar 09, 2021 6:03 pm
by Tougon
Finally got the chance to test this out and it's working great for my purposes, thanks for the help!

Re: Sync Animation to Subtitle printing instead of dialogue end

Posted: Tue Mar 09, 2021 7:55 pm
by Tony Li
Glad to help!