Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#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