Hey… how can i do for add the max and min rotation angle to this script? because so the rotation is at 360°
thank you so much for the support!
#pragma strict
function Update () {
if(Input.GetKey(KeyCode.Z))
{
transform.Rotate (2.5, 0, 0 * Time.deltaTime);
}
if(Input.GetKey(KeyCode.X))
{
transform.Rotate (-2, 0, 0 * Time.deltaTime);
}
}
if you google “clamp rotation unity” comes up with loads of examples, it’s a sticking point for a lot of people.
Clamp being a reference to Unity - Scripting API: Mathf.Clamp
i open the link but i don’t know apply it to my script…
is there an similiar example to apply at my script?
thank you
I have to add this to my script ?
function Clamp (value : float , min : float , max : float) : float {
if(value < min)
value = min;
if(value > max)
value = max;
return value;
}