How to make AI move from its animation played?

Hey guys,

I’m new on UE, I tried to find some answers but nothing found so I’d like your help!

I have an animal blueprint, it has different animations like idle, walk, eat; for the moment, the animal is doing some random animations between those.

I’d like to get which animation is played and if the animation is the running animation, then make move the animal.

The problems are that I don’t find how to get the played animation and make the condition "if it’s “deer_run then make the deer move”.

Could anyone help me?

Thanks in advance and best wishes!

Dyanek

Hey @Dyanek. Welcome to our community!

I’d say you’re thinking wrong:

"if it’s “deer_run then make the deer move”.

I’d not do that. What I’d do is “If Deer is moving, then play the animation.”. And you can easily achieve this with State Machine.

To give you a macro concept:

  1. Create a boolean variable in your Deer’s BP called Is Moving? and make sure its default is false.
  2. Make it move, and as soon as it starts moving, set the Is Moving? variable to true.
  3. When it stops moving, set the Is Moving? variable to false again.
  4. In your State Machine’s Event Graph, you’ll be able to call a node called Try To Get Owner Pawn (or something like this). Just cast it to your Deer’s BP and assign the returned value to a variable with the same type of your Deer’s BP.
  5. With this variable in hands, you can just add an animation to your State Machine and trigger it as soon as a given condition is true/false. In your case, you’d call the variable you just created to mimic the following behavior: When '[Character] Is Moving?' is true, trigger the 'Walk Animation', otherwise keeps playing the 'Idle' animation..

Fundamentally, this is the logic behind to make what you want. Alternatively, you can also blend animations to achieve (almost) the same result, but that’d require an extra effort.

To conclude my answer, I’ll leave the link to Epic’s State Machine Article once again because I think it’s a must-have in order to achieve what I’ve written. Here you go.

All the best buddy!

Hey!

Thanks for your answer and your help, I learnt some things! I must say that even though I managed to do the state machine, I’m lost with other thing but I suppose I’ll manage on my own! I have more important features to do first.