Talking animation loop (Mecanim)

Announcements, support questions, and discussion for the Dialogue System.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Talking animation loop (Mecanim)

Post by harumin »

How to match the loop of a talking animation to the size of the dialogue text?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

Hi,

Is it just a mouth-open / mouth-close animation? If so, give the character an Animator with two states: one for the talking animation, and another for an idle animation. Let's say they're called "Talk" and "Idle". Then set the dialogue entry's Sequence to:

Code: Select all

AnimatorPlay(Talk);
AnimatorPlay(Idle)@{{end}}
To avoid having to enter this for every dialogue entry, you can instead set the Dialogue Manager's Default Sequence.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

Thanks for the reply. Also, I have a continue button on the UI and i had it on always but, how do I give the next conversation node a delay? When I press continue I wanna give it a delay before proceeding to the next.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

So I have it clear: When the player clicks the continue button, it should stop the talking animation, wait for a delay, and then continue to the next stage in the conversation?

If so, here's one way to do that:

1. Change the Sequence to:

Code: Select all

AnimatorPlay(Talk);
AnimatorPlay(Idle)@Message(StopTalking)
2. On the continue button, remove the Unity UI Continue Button Fast Forward if it's there. Instead, add a script like this:

SpecialContinueButton.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SpecialContinueButton : UnityUITypewriterEffect {

    public float delayBeforeContinue = 2;

    public override void OnFastForward() {
        if ((typewriterEffect != null) && typewriterEffect.IsPlaying) {
            typewriterEffect.Stop();
        } else {
            Sequencer.Message("StopTalking");
            Invoke("Continue", delayBeforeContinue);
        }
    }
        
    public void Continue() {
        if (dialogueUI != null) dialogueUI.OnContinue();
    }
}
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

Thanks a bunch Tony :D How do I make Delay() to work? It's only working on conversations that doesn't have a continue button. Example of what I wanna do :
Anemone : We should go back home before the sun sets. (Player clicks continue) (fade out, wait 5 seconds before moving to the next conversation node then fade in.) How do I do it?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

If you want to do this on every dialogue entry, use the SpecialContinueButton.cs script I provided above, but modify it to also fade out and in.

If you only want to do it on specific dialogue entries, here's an example of using an extra dialogue entry node:
FadeDelayExample_2017-03-04.unitypackage

It uses this Sequence:

Image

The Sequence does this:

Time Action
0:00 Fade out
0:01 Show a black cover over the screen (I added "BlackOverlay" to the scene.)
0:06 Hide the black cover
0:06 Fade in
0:07 Continue without requiring the player to click the continue button
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

Thanks. Silly me. I should've consulted the documentation first before posting. Thanks Tony :D
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

No worries! If I can help any more with this, please let me know.
harumin
Posts: 29
Joined: Fri Dec 30, 2016 10:43 am

Re: Talking animation loop (Mecanim)

Post by harumin »

Is it wise to have all conversation entries in just one conversation in the database when making visual novels?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Talking animation loop (Mecanim)

Post by Tony Li »

harumin wrote:Is it wise to have all conversation entries in just one conversation in the database when making visual novels?
It's entirely up to you.

The advantage of one conversation is that everything is visible on the same canvas.

You can also use multiple conversations and link between conversations. To add a cross-conversation link, click on the source dialogue entry. From the "Link To:" dropdown, select "Another Conversation". The advantage of multiple conversations is that you can break up your content, which may make it easier for you to organize and navigate it.

In either case, it's usually easiest to have only one entrypoint in your gameplay -- that is, when starting a new game, always start the same conversation.
Post Reply