I’m attempting to make an xbox controller smoothly rotate a 2D object on its z axis. I have achieved rotation in a multitude of ways, but it’s never smooth. It visibly jumps from 0 to 45 to 90 and so forth. This is running from FixedUpdate. Here are two different attempt examples. What am I doing wrong?
float horizontal = Input.GetAxis ("Horizontal Joystick 2") * Time.deltaTime * 1;
float vertical = Input.GetAxis ("Vertical Joystick 2") * Time.deltaTime * 1;
float angle = Mathf.Atan2 (horizontal, vertical) * Mathf.Rad2Deg;
thisTransform.rotation = Quaternion.Euler (new Vector3 (0, 0, angle));
float currentAngle = thisTransform.eulerAngles.z;
float newAngle = Mathf.Atan2 (CrossPlatformInputManager.GetAxis ("Vertical Joystick 2"), CrossPlatformInputManager.GetAxis ("Horizontal Joystick 2")) * 180 / Mathf.PI;
float angle = Mathf.LerpAngle (currentAngle, newAngle, Time.time);
thisTransform.eulerAngles = new Vector3 (0, 0, angle);