Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSik_the_hedgehog

Posted 09 December 2012 - 04:30 PM

To get the angle between two points: atan2(y2 - y1, x2 - x1). Yeah, there isn't much else to it. Just beware that atan2 returns the value in radians, so you'll need to convert it to degrees (or whatever your game uses).

EDIT: atan2 assumes Y goes upwards and angles are counterclockwise. If either (not both) of these is true, you should use y1 - y2 instead to invert the angle.

#3Sik_the_hedgehog

Posted 09 December 2012 - 04:30 PM

To get the angle between two points: atan2(y2 - y1, x2 - x1). Yeah, there isn't much else to it. Just beware that atan2 returns the value in radians, so you'll need to convert it to degrees (or whatever your game uses).

EDIT: atan2 assumes Y goes upwards and angles are clockwise. If either (not both) of these is true, you should use y1 - y2 instead to invert the angle.

#2Sik_the_hedgehog

Posted 09 December 2012 - 04:29 PM

To get the angle between two points: atan2(y2 - y1, x2 - x1). Yeah, there isn't much else to it. Just beware that atan2 returns the value in radians, so you'll need to convert it to degrees (or whatever your game uses).

EDIT: oh, and if Y is positive downwards instead of upwards, you'll need to use y1 - y2 instead, since atan2 assumes Y goes upwards.

#1Sik_the_hedgehog

Posted 09 December 2012 - 04:28 PM

To get the angle between two points: atan2(y2 - y1, x2 - x1). Yeah, there isn't much else to it. Just beware that atan2 returns the value in radians, so you'll need to convert it to degrees (or whatever your game uses).

PARTNERS