Spawned enemies animation

I have a spawned rat enemy in my game that I would like to follow the player and change animation depending on where the player is such as if the player is to the right of the rat then the rat will turn left.

I have almost got it working but can not the up walk animation to play it seems to interfere with the other animations.

An example video

This is my events

Any Advice greatly appreciated

The problem with the way you’ve used the events is that the last event that holds true is the one that sets the animation.

So if the player character is way to the right and only slightly below a rat, the rat will face down, because that’s the last event that is true.

You’ll need to make a slightly more complex system if you want it to work correctly. You’ll need to get the distance of the player to the rat both horizontally and vertically. Then you need to check which is greater (using abs as this ignores the negative sign), and then base the animation on whether the difference is positive or negative.

Something like this will work:


Thank you worked brilliantly.