Playing Animations on Dialogue Nodes

Announcements, support questions, and discussion for the Dialogue System.
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Playing Animations on Dialogue Nodes

Post 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?
Attachments
Captura de Tela (202).png
Captura de Tela (202).png (7.48 KiB) Viewed 1511 times
Captura de Tela (201).png
Captura de Tela (201).png (13.68 KiB) Viewed 1511 times
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Playing Animations on Dialogue Nodes

Post 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.
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Re: Playing Animations on Dialogue Nodes

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

Re: Playing Animations on Dialogue Nodes

Post 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.
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Re: Playing Animations on Dialogue Nodes

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

Re: Playing Animations on Dialogue Nodes

Post 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).
Strig
Posts: 40
Joined: Fri Aug 21, 2020 12:33 pm

Re: Playing Animations on Dialogue Nodes

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

Re: Playing Animations on Dialogue Nodes

Post by Tony Li »

Great! Glad to help.
Mackerel_Sky
Posts: 111
Joined: Mon Apr 08, 2019 8:01 am

Re: Playing Animations on Dialogue Nodes

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

Re: Playing Animations on Dialogue Nodes

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