Ok, so I’m doing a camera restriction, it restricts the player from looking too much upwards and downwards.
Here’s my code for the camera so far.
var rotation = 0.0;
var current_pitch = 0.0;
function Update () {
rotation = -Input.GetAxis("Mouse Y") * 5;
current_pitch += rotation;
transform.Rotate(rotation, 0, 0);
print(current_pitch);
if(current_pitch < -80.0)
{
//Set the angle back to -80
}
}
I don’t even know if this is the best way to check the rotation. So if there’s a better way to check the rotation of the camera, please tell me.
Now for the restriction line. I tried transform.rotation, but it uses Quaternions for rotation, so I can’t just put down “transform.rotation = -80”. I couldn’t figure out how to do this with the quaternions.