Jump to content
  • Advertisement
Sign in to follow this  
freeworld

calculate the angle to face towards a point (2D)

This topic is 3380 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

How would I calculate the angle one object would have to be at to face annother object, in 2D. everything I've searched suggested that the this would do it.... atan2( y2-y1, x2-x1); but it just keep returning values ranging from -1.3 to 0.01... and so forth wich do seem to be usefull. I thought maybe they were in radians so I converted to degrees but it didn't make any notice difference to put it in the range of 0-360 or even -180 - 180; any help on this would be most appreciated.

Share this post


Link to post
Share on other sites
Advertisement
First things first:
1) What language? C++?
2) What does your radians to degrees conversion look like?
3) Post the surrounding code (in [source] code here [/source] tags, please)

How do you know it isn't right? Have you validated the values by hand, or are you using them to draw something that doesn't look right?



Share this post


Link to post
Share on other sites
Original post by jouley
First things first:
1) What language? C++?
2) What does your radians to degrees conversion look like?
3) Post the surrounding code (in
 code here 
tags, please)

How do you know it isn't right? Have you validated the values by hand, or are you using them to draw something that doesn't look right?[/quote]

figured it out, I was converting radians to radians making things really really small.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!