clamping camera's rotation
I have it set up to where the camera should only go to certain point before it stops rotating, but when I try, the camera will not move up or down. please help.
code c#
Vector3 rot = transform.eulerAngles;
float vertical = Input.GetAxis ("Mouse Y") * rotateSpeed;
target.transform.Rotate (-vertical, 0, 0);
float desiredAngle = target.transform.eulerAngles.y;
Quaternion rotation = Quaternion.Euler (desiredAngle, 0, 0);
transform.position = target.transform.position - (rotation * offset);
rot.x = Mathf.Clamp(rot.x + vertical, vertical, -vertical);
transform.eulerAngles = rot;
transform.LookAt (target.transform);
Comment
vertical changes based on mouse position, so how can you tell it's clamping? the clamp value keeps changing... so it'll never 'limit' anything...
Your answer
![](https://koobas.hobune.stream/wayback/20220612045521im_/https://answers.unity.com/themes/thub/images/avi.jpg)