I am working on a game in which I need an enemy ship to point towards the player.

Here is the equation I came up with:

angle = sin-1(abs(y1 - y2)/√(x1 - x2)2-(y1 - y2)2)

This essentially takes the inverse sine of the opposite divided by the hypotenuse. Unfortunately, this algorithm does not work. Any ideas as to what I need to change? Note, the angle is a radian value.


1 Answer 1


atan2(y1-y2, x1-x2)
or maybe atan2(-(y1-y2), x1-x2), depending on the coordinate system.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .