Rotation back to its original position

hi!!

I am trying to do an effect when the mouse moves to an object, it will move in its z axis which is already working, here’s my script for it :

function OnMouseOver()

{

transform.Rotate( 0, 0, Time.deltaTime*150);

}

function OnMouseExit()

{

transform.Rotate( 0,0,0);

What I am trying to achieve is that when the mouse leaves the object, it will move back to its original position.

Please help me!!

Thanks!!!

what is the problem you are facing and what do you want the object to do when mouse leaves it

1 Answer

1

You will need to store the original rotation in a Quaterion member.
You can set a quaternion member _StartRotation in the Start function, and each time you need to restore the original rotation, you will just need to do transform.rotation = _StartRotation;

Cheers

I got the script and its working but it stopped in a different angle. here the script: transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.identity, Time.time * 1); please help! thanks