Script not recognizing rotation

OK, so i’m trying to rotate a platform until it reaches 90 degrees and then stop, it rotates, but goes beyond 90 degrees, if i change the < to a > it doesn’t rotate, so i’m guessing it works with some kind of local rotation value, even though i can see the y value of rotation go beyond 90 in the inspector when i run it… how can i get it to compare to an absolute value? thanks in advance…

function Update () {
	if(transform.rotation.y < 90){
	transform.Rotate(0,1,0);
	}
	else {
	transform.Rotate(0,0,0);
	}
}

Hi. The problem here is that transform.rotation is a Quaternion and the “y” component is not degrees. What you want to check against is eulerAngles. So if(transform.rotation.y < 90) becomes if(transform.eulerAngles.y < 90). You may also want to scale the rotation amount to time. Also, the else statement is rotating by nothing so can be omitted:

var rotationSpeed:float = 90;
function Update ()
{
	// eulerAngles is rotation in X,Y,Z in degrees
	// localEulerAngles are relative to its parent
	if(transform.eulerAngles.y < 90)
	{
		// Rotation is now in degrees per second
		transform.Rotate(0, rotationSpeed * Time.deltaTime, 0);
	}
}

I hope that helps. =)