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


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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.