In desktop version, my character's arm is rotates according to the movement of the mouse. I need the same thing in mobile version but this time I need a joystick to rotate his arm. How can I do that?
//Here is my code, for rotating arm
void Update()
{
float horizontal = Input.GetAxis("Joy Y") * Time.deltaTime;
float vertical = Input.GetAxis("Joy X") * Time.deltaTime;
float rotZ = Mathf.Atan2(horizontal, vertical) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
}
I have changed the code a bit, for now player arm is rotating but, this time there is another problem. Arm is doing unexpected movements when I try to move with joystick I think joystick is mixed with mouse. I don't know how to seperate it?