I placed the code in and am looking for the model to never rotate past 30 degrees(later be put into variable) but the clamp doesn’t seem to be working. not sure where to look for the answer to this or where to look for better explanation on this. would I be better off working with eulerangles?
First, transform.Rotate is already working with euler angles. With that function call you are rotating your transform N degrees in the X axis. Note that in euler angles, -30 is the same as 330 and 690.
I recommend you to debug the value of vertMovement * (pitchRotSpeed * Time.deltaTime) with:
That way you can now if the value range. If the value gets below -180 or above 180, you could move it to a better range with something like this:
if (angle > 180)
{
angle -= 360;
}
else if (angle < -180)
{
angle += 360;
}
Another important thing is to decide if you want global rotation or local rotation. That is important if the transform is children of another transform. Local rotation can be applied with:
transform.localEulerAngles += new Vector3(x, y, z);