- Home /
This question was
closed Jun 12, 2021 at 06:12 PM by
andrew-lukasik for the following reason:
The question is answered, right answer was accepted
Rotate object based on normalized Vector2?
I am trying to use a touch joystick to control the rotation of my player's gun in 2D. The joystick returns Vector2 with a magnitude of 1. (Left is -1, 0 and Up is 0, 1)
How could I turn that Vector into a 360 degree rotation?
Comment
Best Answer
Answer by lolzrofl · Oct 13, 2014 at 05:00 AM
Actually I finally solved it myself.
float gunRotation = Mathf.Atan2(joystickVertex.y, joystickVertex.x) * Mathf.Rad2Deg;
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer