i want to change position of two object…
means they interchange their position and the movement is seen in scene view
anyone who know please help me…
static var object1:Vector3;
static var object2:Vector3;
static var object3:Vector3;
static var moving:boolean=false;
static var check:boolean=false;
static var next:boolean=false;
var speed:float = 5.0f;
private var weight : float = 0;
var liftSpeed : float = 1;
function Update () {
if(check) {
check=false;
startPosition =object1; //Set the start
weight += Time.deltaTime * liftSpeed; //amount
transform.position = Vector3.Lerp( startPosition, object2, weight);
transform.position = Vector3.Lerp(object2, startPosition, weight);
next=true;
Debug.Log("update one ");
}
if(next){
transform.position = Vector3.Lerp(object3, object2, weight);
transform.position = Vector3.Lerp(object2,object3, weight);
Debug.Log("value of start "+startPosition);
Debug.Log("value of end "+object2);
Debug.Log("update two");
}
}
function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.name == "Glassfour"){
Destroy(gameObject);
object1=GameObject.Find("Glassfour").transform.position;
object2=GameObject.Find("Glassone").transform.position;
object3=GameObject.Find("Glasstwo").transform.position;
Debug.Log("Glassfour orignal position "+object1);
Debug.Log("Glassone orignal position "+object2);
Debug.Log("Glasstwo orignal position "+object3);
var position1 : Vector3 = object1;
Debug.Log("after Swaping ........");
object1 = object2;
object2= position1;
check=true;
Debug.Log("Glassfour changed position "+object1);
Debug.Log("Glassone chenged position "+object2);
//startPosition =object1; //Set the start
}
}