Hi everyone, I am making a cameraRotation script in Unity and for the vertical Rotation of the camera I tried the following approaches:
-
Getting the local rotation of the camera, then subtracting the vertical mouse input from it then applying it to the camera local rotation.
-
Inverting the vertical mouse input and then applying it to the local rotation of the camera
I wanna know which approach is optimal / efficient and if there is any other approach to it
Another question I have is that: Whenever I directly clamp the vertical rotation of the camera and then apply it to the local rotation of the camera it causes crazy jitter when maximum value is reached and when I restore the value in the same variable after clamping everything works fine
newVerticalCameraRot = Mathf.Clamp(newVerticalCameraRot, -90f, 90f);
this.transform.localRotation = Quaternion.Euler(newVerticalCameraRot, 0f, 0f);`
The above works fine
But this doesn’t
Mathf.Clamp(newVerticalCameraRot, -90f, 90f);
this.transform.localRotation = Quaternion.Euler(newVerticalCameraRot, 0f, 0f)
Thank you for reading