Okay so I have this script attached to an empty gameobject that serves as a parent for two child objects underneath, what I want to do is to rotate the parent object which works perfectly fine until I try to clamp the rotation. Here’s what I’ve got so far:
#pragma strict
var rotSpeed : float = 5.0;
var rotOn : boolean = false;
function Update () {
if(Input.GetButton("Jump" || rotOn == false)){
rotOn = true;
}
if( rotOn == true){
transform.Rotate(0,0,-rotSpeed * Time.deltaTime);
transform.rotation.z = Mathf.Clamp(transform.rotation.z, 360.0,270.0 );
}
}
The reason why I set it to clamp between 360 and 270 degrees is because at runtime, -90 degrees is the same as 270 and I have no idea why, the clamping also makes my object “snap” to about 180 degrees and won’t move. What might be the problem? Is there a diferent kind of rotation at runtime than “outside” of runtime? Anything that will help me understand what I am doing wrong will most certainly be of help. Thanks in advance ![]()
Ah! that made it work. I didn't know that rotation was stored as a Quaternion. Thanks!
– Lemonizer