Get physical object movement angle for animation(SOLVED)

Hello, I’m making NPCs (Physics 2.0 objects with 0 gravity) for a top-down game and can’t figure out how to do the animations for them, walk-cycles in 8 directions, basically the same thing you can see in “Isometric game” example, but for a Physics 2.0 object.

Is there a way in Gdevelop to get the movement angle of a physics 2.0 object?

Hi,
Have you tried ObjectName.Angle() ?

Yes, but i need to get the angle of the movement, not the angle of rotation of an object, since my objects have fixed rotation in order to display character sprite correctly.

I see.
Unfortunately, there’s no expression for this, but it seems you can compute it likeso:

1 Like

Thanks, this seems like the right approach to do this, but the problem is that the angle value is “mirrored” so the animation only plays correctly when they go down.
Giff

Well, I finally figured out how to do it:


Among other things, you need to swap animations 5 and 7, so everything will be displayed correctly.
image
Here is the result:
ezgif-4-9fe5c48d08

2 Likes