I'm trying to design a 2D game and am working on monster movement right now.
I need to calculate the angle a monster moves towards when they move from location A to location B (so I know which direction the monster should face when they move).
I know the formula to calculate the angle is atan2(Y1 - Y2, X1- X2), but I'm having a hard time understanding which value is which.
For example if the monster moves from PointA to Point B, the monster should be facing PointB while it moves. So which Point references X1/Y1 and which Point references X2/Y2.Would X1/Y1 be PointA (the origin) or would it be PointB (the destination)?
The atan() gives you the angle to the horizontal axes. (A is (x1,y1) the starting point, B is (x2,y2) where your monster goes and faces