So i have an object that i want to rotate when the cursor is on screen but when i move the cursor off screen i want it to return to its original position.
this is my code but it doesn’t work.
var joint : GameObject;
var joint1 : Transform=joint.transform.rotation;
function Update () {
if mouse on screen do this.......
joint.transform.Rotate(Vector3(0,-1,0)*(Time.deltaTime));
if mouse not on screen....
joint.transform.rotation = Quaternion.Lerp(joint.transform.rotation, joint1, Time.deltaTime*100);
}