Resume AI Behavior Tree Animation

Hi, so for my AI character, I want it to play an eating animation when the player feeds it candy and then resume its regular behavior tree animation after that. But after the animation plays out, all animations for the character stop. Is there a way to allow it to play the animation I want it to temporarily and then resume the behavior tree sequence with all animations playing again (idle, walking, running)?

Hey @Zapking9224!

Would you mind sharing how you are setting the animation in your behavior tree? Are you using a animation blueprint or setting it using a different method?

Any additional specifics or information you can provide will be a big help!

Hey @Quetzalcodename! So I have an animation blueprint for the AI which only tracks its speed. Not moving = idle anim, Slower speed = walking Anim, and Faster speed = running anim. So the behavior tree just moves the AI around the map and depending on the conditions met, itā€™ll have it either stand still, walk, or run around and that all works fine. But what I want to happen is the player feeds the AI goblin a piece of candy and the goblin should play an eating animation on that event. My initial idea was to just play an animation when the player presses ā€˜eā€™ to feed to candy, but after the eating animation is done playing, the goblin just freezes and Iā€™m not sure how Iā€™d go about unfreezing it. It still roams around the world, it just doesnā€™t play any animations.

Hey @Zapking9224,

Itā€™s still not clear what method you are using to set your animation states. Is your eating candy event on your tree so that it may transition between your movement and your eating animation, similar to how jumping is handled, or something else?

Images of your animation blueprint states/transitions and what methods you are using to change between the states on your behavior tree/blueprints would give a lot more pertinent information to your current situation!

The first picture shows the run branches where either the goblin runs away from the player if you arenā€™t holding the candy (right branch) and the goblin runs towards the player when they are holding the candy (left branch).

The Second picture shows a 1D blendspace which blends the idle, walking, and running animations together depending on the goblinā€™s speed.

The third picture shows the event within the player character blueprint where when the player is near the goblin and some other conditions are met, the player can give the candy to the goblin and the goblin plays the ā€œhitā€ animation. After that animation is run, it stops the animation blueprint (fourth picture) from having an effect on the goblin I guess because the goblin just freezes with no animations playing at all even as the behavior tree continues its execution.

The fifth picture shows the ā€œplay animationā€ function that I created within the goblin character.

I believe thatā€™s all of the places I create and use any sort of animation.




image
image

Hey @Zapking9224,

Both the beginning and end of your third image are cut of so we canā€™t really see how you transition in, thatā€™s what is important in this situation, not necessarily what the assets are playing.

What I can tell however, is that you have not set up any way for your animations to return to the locomotion state. For what you are trying to do, unless you are using the built in play animation (which may not work in your situation due to complexity) ai node, you will want to instead change a transition rule with your AI blueprint so your goblin knows when to resume running away animations.

Check out this great non-Epic affiliated video on setting up your animation blueprint state machines that already has an identical (idle/walk/run) node:

I hope the above is the solution you need.

Hey @Quetzalcodename. Thanks for helping me out. I didnā€™t have the transitions set up. Everything is working great now!

1 Like