(Solved) How do I best calculate the angle from one object to another?

For a head up display I’d like to display the direction the player has to move to find another object.

While I can setup a nice arrow sprite this is about the angle it needs to point to. I do not just want to use arctan(y1-y0/x1/x0) as this will have two blind spots. Somehow I was searching gdevelop5:objects:base_object:events [GDevelop wiki] but it reveals actions rather than functions…

It seems I am searching for something like getAngleToObject(), similar like https://docs.gdevelop-app.com/GDJS%20Runtime%20Documentation/gdjs.SpriteRuntimeObject.html#getDistanceToObject

1 Like

If you know Javascript I think you can use arctan2 for that.

2 Likes

Short anwer that nailed it.
I was not aware of that function. Thanks a lot! :slight_smile:

2 Likes