restore rotation

Hi …
I have a function that rotates an object and want to do something that restores the original values ​​of rotation, but not work for me …

the script is part of the component object,

var Speed : float = 150;
var ok : boolean = false;

function Update () {
if(ok==true){
transform.Rotate (0.0, 45.0,Speed * Time.deltaTime);
}
}

function ResRotation(){
ok = false;
transform.Rotate(5.0,0.0,0.0);
}

Thank for your help!!

Pb

This resets/restores the rotation to a specific angle, like in your script, 5 degrees:

transform.rotation = Quaternion.Euler( 5.0, 0.0, 0.0 );

Or reset/restore to “no rotation” using the identity rotation:

transform.rotation = Quaternion.identity;

Thank you very mush!! :slight_smile: