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?
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?
Actually I finally solved it myself.
float gunRotation = Mathf.Atan2(joystickVertex.y, joystickVertex.x) * Mathf.Rad2Deg;