How to rotate the camera vertically from its point of view (maintaining its forward orientation) until it reaches a point pointing horizontal or vertical with the world plane?
I know, it sounds simple, but I've been at this for many hours and have tried many methods posted here (setting the transform rotation directly in the update step, calling transform.rotate with Quaternion slerping, comparing degrees between vectors, testing quaternion.angle(s), trying quaternion.rotatetowards, etc etc etc) but I must keep getting an axis wrong or something.
In my world, the XY plane is the ground and Z is "up". For implementing a RTS style camera, it was easy to work out how to pitch the camera up and down
transform.Rotate(Vector3.right * Time.deltaTime * rotationSpeed, Space.Self);
or rotate left and right
transform.Rotate(Vector3.forward * Time.deltaTime * rotationSpeed, Space.World);
What I can't work out how to do, is when pitching up and down, to only allow you to pitch the camera until it is pointing straight down, or straight ahead, and neatly stop the camera at that point without it nearly but not getting there, or jittering almost at the right point.
How would I go about it?
Your answer
![](https://koobas.hobune.stream/wayback/20220612140147im_/https://answers.unity.com/themes/thub/images/avi.jpg)