Enemy Pathfinding Animations

Hello, I can’t find a way to change the animations of my enemies with pathfinding behavior when they chase the player and can’t find recent solution to this problem. The view of the game is Isometric and I want to make my enemies to have the correct animation to the direction they face. It feels like easy task to do, but for some reason I can’t manage to make it work. Can some one help?

Hi and welcome back. :slight_smile:
This is the first event of the isometric example:


Have you tried something like that?

Thanks’ for welcoming back, feels good to make games again :smiley:
About the rotation I can’t make it work still trying, but no success.


This is my event, I have 4 animations for the directions of the sprite, no idle animation. Order of the animations are clockwise, right=0 down=1 left=2 up=3 and still don’t switch them in right order or even don’t do it every time the object is rotated but no animation changed. I see in the isometric example is using something like “TopDownMovement::Angle()” and try to use “…Pathfinding::Angle()…” but then don’t allow me to use pathfinding as command. And I’m stuck here :smiley:

Yes, I’ve been stuck on the same thing a few months ago and have moved onto other things for now. A few people have come up with work around solutions but they are complicated for something that could be simple. And in some of the old threads on this topic, two different GD team members made the same recommendation as Gruk to use the isometric example, but pathfinding just doesn’t seem to work with it.

The only solution I found is to attach the sprite to invisible one witch have absolutely the same settings as the original and use his directions to change the main sprite animations it works but no every time and its frustrating, when two enemies came across each other the blocks get bugged. Feels this should be easy but its not the case at all.

I believe ObjectNameHere.Pathfinding::MovementAngle() is the expression you’re looking for. It’s also listed in the expression builder:

image

Edit: Also, since you’re not using any conditions to target a specific object, you’ll likely need to use the “For Each object” event type to make sure you don’t run into conflicts.

Ohhh. I had already tried this in the action:

ObjectNameHere.Pathfinding::MovementAngle()

before posting but did not have the condition you mentioned. So I think this is what you mean:

It works only sometimes, but it’s a start.

This angle=angle condition looks quite useless. :thinking:

Haha, yes, but I didn’t know any other way of interpreting Silver-Streak’s suggestion.

I just don’t get it. I tried the example file here:

but it didn’t change the animation, it changed the angle of the player. And it was difficult to understand so I didn’t know how to apply those principles.

Here is an example I made using the mouse position as the pathfinding destination, although this is not how I will be setting it in my actual game. I didn’t know what to put here in the highlighted section to make it just one event to change for all angles like is done in the isometric example for top down movement.


So I did them separately as shown here but even that doesn't work. What am I doing wrong? For this example, the left and right animations never show and the up and down ones are wrong most of the time. It's currently got a 22° tolerance, I also tried zero.

1 Like

What animation is supposed to trigger when the angle is 45, 225, or 315?
A tolerance of 22 degrees is okay if you have 8 animations. Try doubling it.

Oh, that makes sense. But I don’t have diagonals allowed though so I (wrongly?) assumed the tolerance wouldn’t make any difference. I changed them all to 44° but the problem remains, the left and right animations never happen and the up and down ones just change only sometimes, usually when the right or left one should happen.

Ah, okay.
Well, you set up a text object displaying the movement angle, so check that value to find out what’s going on.

Thanks for checking back. The angle display doesn’t show any weirdness, it shows the angle that is expected but the animation doesn’t match.

If this is a problem with the way I’m doing then I don’t know what else to try. But has anyone ever actually got this to work?

Please see here for a working example from MrMen:

1 Like