Jump to content
  • Advertisement
Sign in to follow this  
PlutoWarrior

Aiming a turret at the mouse

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

So I understand the math behind getting my turret to aim at the mouse. Take the vector between the rotating point of the turret and the mouse, and the vector between the rotating point and the tip of the turret, normalize them, and take the dot product. Then use acos of that number to get the angle in radians. I then use that angle (converted to degrees) to give to openGL to rotate the quad. The issue I'm having is keeping track of the vector from the rotating point to the end of the turret. After openGL does the first rotation I no longer know the x and y coordinates of that point. Should I do the rotation myself, or is there a better way of doing this than what I'm thinking? [Edited by - PlutoWarrior on November 28, 2008 12:25:29 PM]

Share this post


Link to post
Share on other sites
Advertisement
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!