If your object is only rotating on the 'y' axis, you can do:
var euler = transform.eulerAngles;
euler.y = Mathf.Clamp(euler.y, 5.0, 17.0);
transform.eulerAngles = euler;
The problem is significantly more complicated if you are allowing rotation on multiple axes. I'd need to see your rotation code in order to advise.
↧