Jump to content
  • Advertisement
Sign in to follow this  
Kaze

angular resolution

This topic is 4949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im making a rpg where you move the character by clicking a point and letting you character move there(like starcraft and red alert 2) does anyone know a way to find the angle between two points that works for 0-360 insted of 0-90 and is more gracefull that combining the 0-90 one with if statments EDIT:sorry can anyone move this to math and physics section

Share this post


Link to post
Share on other sites
Advertisement
As SiCrane already said, use atan2:

double dAngle = atan2( deltax, deltay );

deltax is the difference in x, deltay the difference in y.
The resulting angle is in radian, you can store it that way or transform to degree by multiplying with 180.0f / PI.

Also, you might take in account that y on the screen is usually downwards, while mathematically y points up (If you need to do that you just use -deltay in atan2).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!