Hello,
I have attached my camera to my player so that the camera is following my player. I then created a c# script to rotate the camera according to my Mouse Y axis. After that i tried to cap the rotation to specific angles to prevent a 360° rotation. But it wont work. Here´s my code:
void Update() {
float rotX = -Input.GetAxis("Mouse Y") * 5;
if (rotX < 0 && transform.rotation.eulerAngles.x > -30) {
transform.Rotate(rotX, 0, 0);
}
if (rotX > 0 && transform.rotation.eulerAngles.x < 30)
{
transform.Rotate(rotX, 0, 0);
}
}