Trying to clamp camera position causes it to get stuck for a few seconds.

yaw += camSpeed * Input.GetAxis(“Mouse X”);
pitch -= camSpeed * Input.GetAxis(“Mouse Y”);

Vector3 direction = new Vector3(Mathf.Clamp(pitch, -90, 90), yaw, 0.0f);
Camera.main.transform.rotation = Quaternion.Euler(direction);

My code for rotating the camera is the above. However, when I try using this code, it works… mostly. When I go to one of the limits for long enough, it gets stuck there unless I apply a lot of force moving it back. How would I fix this?

Don’t clamp the value in the new vector, clamp it when you are managing input.

pitch = Mathf.Clamp(pitch - camSpeed * Input.GetAxis("Mouse Y"), -90, 90);

When you clamped in new Vector3, you did not clamp pitch itself, you clamped the x component of your new vector. Pitch continued to rise above 90 and fall above -90. Now, since pitch is clamped, you can simply use:

Vector3 direction = new Vector3(pitch, yaw, 0);