Change object's transform to it's previous transform.

I need to change the object transform and again bring it back to it’s previous transform, so I defined a Transform type called TempTransform, to save the current transform.

var FirstPerson: GameObject;
var TempTransform: Transform;
var jalousie : GameObject;

function Start ()
{
TempTransform=FirstPerson.transform;
Debug.Log(TempTransform.rotation.y + "and" + FirstPerson.transform.rotation.y);
yield WaitForSeconds(1);
FirstPerson.transform.LookAt(jalousie.transform);
Debug.Log(TempTransform.rotation.y + "and" + FirstPerson.transform.rotation.y);
}

but when I change the FirstPerson’s transform, the Temptransform changes as well. I don’t get the reason why?? any idea?

TempTransform.rotation = FirstPerson.transform.rotation;

Hi,
This might help :slight_smile:

var FirstPerson: GameObject;
var tempTransformroattion_y:float;
 var jalousie : GameObject;
 
 function Start ()
 {
 
 tempTransformroattion_y = FirstPerson.transform.rotation.y;
 
 Debug.Log(tempTransformroattion_y + "and" + FirstPerson.transform.rotation.y);
// yield WaitForSeconds(1);
 FirstPerson.transform.LookAt(jalousie.transform);
 Debug.Log(tempTransformroattion_y + "and" + FirstPerson.transform.rotation.y);
 
 }