- Home /
Mimic rotation from a joystick
I have a circle and I'd like it to mimic the direction the joystick is facing. The circle can only be rotated. The values I get from the joystick are a Vector2, for example: -0.3, 0.8
How do I rotate the circle to match the joystick?
Comment
Best Answer
Answer by Riiich · May 06, 2020 at 10:03 PM
Solved it with this code
joystickAngle = Mathf.Atan2(axis.x, axis.y);
joystickAngle = joystickAngle * Mathf.Rad2Deg;
rotator.localRotation = Quaternion.Euler(0, joystickAngle, 0);