1
\$\begingroup\$

i have object in game which is rotating when i move my joystick , now i need to calculate its movement vector by its rotation
the object always moving forward and controlled by the joystick , the joystick is only setting its direction by degree .
here is the image which illustrate the scene .
i need some formula of the vector which the object will move .

enter image description here

\$\endgroup\$
1

1 Answer 1

1
\$\begingroup\$

Enter trigonometry!

To calculate the velocity vector of the ship, you need to use the following formula:

v.x := sin(angle) * velocity
v.y := cos(angle) * velocity

Also, if your angle is in degrees, you may need to convert it to radian:

angleInRadian := angle / 180 * pi
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .