If you post a code snippet, ALWAYS USE CODE TAGS:
How to use code tags: Using code tags properly
The problem you report is likely from gimbal lock.
Notes on clamping camera rotation and NOT using .eulerAngles because of gimbal lock:
How to instantly see gimbal lock for yourself:
1 Like