Page 1 of 2

Playing Animations on Dialogue Nodes

Posted: Mon Dec 14, 2020 3:59 pm
by Strig
I'm currently trying to implement some animations during dialogue - specifically inside the nodes (image 1).

The problem is, the animations either don't play or I get this error message (image 2)

What am I doing wrong and how can I play the animations?

Re: Playing Animations on Dialogue Nodes

Posted: Mon Dec 14, 2020 8:01 pm
by Tony Li
Hi,

That means the subject's Animator doesn't have a state named "FallLeft".

Temporarily set your Dialogue Manager's Other Settings > Debug Level to Info.

When the conversation gets to that node, the Dialogue System will log 2 messages to the Console window. The first message shows what the sequencer has parsed. Something like:

Dialogue System: Sequencer: Play( AnimatorPlay(FallLeft)@0 )

The second message shows what GameObject is being used as the subject. Example:

Dialogue System: Sequencer: AnimatorPlay(FallLeft, NPC_X)

Make sure it's the correct GameObject. See Character GameObject Assignments for more info.

Re: Playing Animations on Dialogue Nodes

Posted: Tue Dec 15, 2020 9:52 am
by Strig
Thanks for the quick reply, as always!

The messages display as intended and the subject does have a state called "FallLeft" in the Animator. But the animation doesn't play. I found out that by using AnimatorPlayWait, the animation does play, but only for a split second.

Could it be some Animator configuration, maybe?

Re: Playing Animations on Dialogue Nodes

Posted: Tue Dec 15, 2020 11:22 am
by Tony Li
Yes. Almost certainly, the FallLeft state has a transition that's firing as soon as the animator enters the FallLeft state. Check the conditions on that transition arrow. You may need to either remove the transition arrow or an additional sequencer command such as AnimatorBool() to prevent it from immediately transitioning away from FallLeft.

Re: Playing Animations on Dialogue Nodes

Posted: Tue Dec 15, 2020 12:42 pm
by Strig
I see. I did as you suggested and managed to find a workaround.
Captura de Tela (204).png
Captura de Tela (204).png (8.19 KiB) Viewed 1492 times
This is because of the way our Animator is set up - all states are linked to Any State and have Fixed Duration ticked on. All of these states are actually Blend Trees that contain the different Animations (the different nodes you see without any transitions).
Captura de Tela (203).png
Captura de Tela (203).png (38.59 KiB) Viewed 1492 times
So the workaround works fine, but is there another option? Maybe a small rework I could do to the Animator so I don't need to set up several different Animation Bools just to get the animation to play? What would you reccommend?

Re: Playing Animations on Dialogue Nodes

Posted: Tue Dec 15, 2020 12:47 pm
by Tony Li
Hi,

The animator controller is a state machine, and by nature state machines have transitions. That's how they automatically change states. You could change the parameters that affect the transitions -- for example, add an isInDialogue bool parameter, and make all Any State transitions require that the bool is false. Or you might find it easier to remove the Any State transitions and have transitions from state to state. Then you can add separate states for dialogue (e.g., WalkLeftCutscene).

Re: Playing Animations on Dialogue Nodes

Posted: Fri Dec 18, 2020 8:21 am
by Strig
It worked! We set up our Playmaker FSMs in a different way and made new, Dialogue-specific Animator nodes without any transitions, as you said. Then we just call the FSM Event through the Dialogue Node.

Thanks for the help!

Re: Playing Animations on Dialogue Nodes

Posted: Fri Dec 18, 2020 10:08 am
by Tony Li
Great! Glad to help.

Re: Playing Animations on Dialogue Nodes

Posted: Mon Jan 04, 2021 7:34 am
by Mackerel_Sky
Hey Tony,

Sorry for hijacking this thread. I've run into a similar issue and followed the steps that Strig and you laid out earlier. In my case, AnimatorPlayWait didn't work out for me.

Here's my Debug Info window:

Image

I've already removed any transitions from the Receptionist Back state like so:

Image

The state is a single frame as it's a still image I'm experimenting with for now. The idea is that it's supposed to be held for 2.5 seconds, hence the delay sequence right after.

Would you have any other ideas on how to fix this?

Thanks premptively for your help, and hope you had a safe and happy New Years :0

Re: Playing Animations on Dialogue Nodes

Posted: Mon Jan 04, 2021 9:59 am
by Tony Li
Hi,

If you inspect that GameObject and keep an eye on the Animator window, does it transition into that state?

You may need to add a second frame with the same keyframe values.

Also, since you're waiting 2.5 seconds, you can use AnimatorPlay(). If you want to go back to idle after, you can use @time:

Code: Select all

AnimatorPlay(Receptionist Back, Receptionist);
required AnimatorPlay(Receptionist Idle, Receptionist)@2.5