I’m trying to rotate a sprite on the Z axis with the use of a Virtual Joystick from the “Joystick Pack Free” asset. I’m using the code below but it doesn’t work as I want to.
transform.eulerAngles = new Vector3(0, 0, joystick.Horizontal * joystick.Vertical * -160);
This script is part of the sprite, and joystick is a public Joystick.
I tried this code too:
transform.eulerAngles = new Vector3(0, 0, (Mathf.Atan(joystick.Vertical / joystick.Horizontal)) * -45);
Neither or which works. I tried with many values but it doesn’t seem to work.