How to make object point towards another (2D)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By James122333

i want an object to look at the position of the player (the player in my game doesn’t move)

I have the information of the location of the player but the object does

player_pos = $"/root/Global".player.get_position()

can anyone help me to covert the player position to an amount of degrees to turn to point towards

:bust_in_silhouette: Reply From: Lopy

The movement from the point A to B is B-A.
You can then replace the resulting Vector with it’s normalized() form, to make it of length 1.
With that, you get the angle in radians using acos() on the Vector’s x, see Unit Circle. Multiply the value by -1 if y is negative
Finally, radians can be converted into degrees using rad2deg().