I have an object, and i want to clamp the z value between -90, and 90. So it has a total of 180 degrees it can go. This is my problem, when in play mode, it is no longer -90, and it is 270. So i need to clamp my angle from 90, to 270, mathematically this is from 90 to 270, but i want it to include 0 to 90, and 270 to 360 its hard to explain so i made a picture right here : http://puu.sh/iB8Lo/f18dede505.png
here is my code in case i’m doing something wrong
Quaternion clamp = Quaternion.Euler(transform.localEulerAngles.x, transform.localEulerAngles.y, Mathf.Clamp(transform.localEulerAngles.z, -90, 90));
transform.rotation = clamp;