Rotation Question...

Hi. When a button is clicked, I want an object to rotate 90 degrees and then stop…and I want that rotation to take exactly 2 seconds. When I try this bit of code, the rotation is always a few degrees off (it rotaes about 94 degrees)…why? Thanks

var Can_Spin = false;
function OnGUI(){
		if (GUI.Button (Rect( Camera.main.WorldToScreenPoint (transform.position).x-15,Screen.height-Camera.main.WorldToScreenPoint(transform.position).y-.5f,25, 15),"")) {

function Phase_1(){
function Update(){
		if(Can_Spin==true){transform.Rotate(Vector3.forward * Time.deltaTime*90/2);}

Probably because in the time for it to run that code it kept rotating another 4 degrees. You’ll have to find out how many degrees it’s turning per frame and then multiply that by 90 and it’ll only spin 90 degrees.

This can be accomplished by using Quaternion.Lerp