rotation based on mouse coordinates
Hi, in my top down 2d game i want it so that when the mouse is moved the player rotates to face the cursor. My problem is that i don''t know how to use the coordinates to determine the angle the player will face. Does anyone know how to do this or have any suggestions?
+AA_970+
using tan, of course!
first, figure out the x disntance between the mouse and the player, and the y distance between the mouse and the player. then use the formula:
tan x = y/x
then use the special arctan function using y/x to find x, which is the angle.
first, figure out the x disntance between the mouse and the player, and the y distance between the mouse and the player. then use the formula:
tan x = y/x
then use the special arctan function using y/x to find x, which is the angle.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement