I am implementing an animal that can attacked the player. After it attacked it has to jump away from the target to get out of harm’s way.
I am using a Behavior Tree and have a hard time implementing it in a BTTask. In detail the following has to happen:
- Play attack animation while moving closer to the player (animation: jump attack)
- Wait for the attack animation to finish and the movement to player is done
- Play flee animation while moving away from player again (animation: jump backwards)
The Moving to player and moving away works fine. But I cannot get the right animation played when it moves to the player (jump attack) and when it moves away (jump backwards).
One idea I tried is to have two new states for it in the animation graph, but how can I make sure that the animation state switches when the attack animation is finished AND the motion towards the player in the behavior tree is done?
In theory I could implement an BTDecorator that checks variables where I somehow aggregate this two states. Is there an easy way to accomplish this?