So I’m trying to rotate an object from -35 degrees and 35 degrees, or rather 325 degrees to 35 degrees and I’m trying to lock the rotations there.
I have this code:
void lockRotationUp() {
Rotation.x = transform.rotation.eulerAngles.x;
Rotation.x = Mathf.Clamp (Rotation.x, 325,35);
transform.localEulerAngles = new Vector3(Rotation.x, transform.localEulerAngles.y, transform.localEulerAngles.z);
}
but it just flips between 325 and 35 degrees, no in-the-middle, but if I write it this way:
void lockRotationUp() {
Rotation.x = transform.rotation.eulerAngles.x;
Rotation.x = Mathf.Clamp (Rotation.x, -35,35);
transform.localEulerAngles = new Vector3(Rotation.x, transform.localEulerAngles.y, transform.localEulerAngles.z);
}
it freaks out when it hits zero, does anyone know how to properly lock the rotation from 325 degrees to 35 degrees?