public Camera Camera;
public float speed = 0.1f;
void Update()
{
if (Camera.transform.eulerAngles.x > -90)
{
Camera.transform.Rotate(-1, 0, 0 * speed * Time.deltaTime);
}
}
I’m using this code above and instead of stopping at -90 it just keeps going around in circles.
Keep your own float for the rotation angle and set it into the rotation. Here’s why:
Notes on clamping camera rotation and NOT using .eulerAngles because of gimbal lock:
How to instantly see gimbal lock for yourself: