# How can I get it from point b to point c

I have a sphere, right now I have it traveling to the position of a cube. how do I get it to travel to the position of another cube only after hitting the first one? here's my script.

``````  var start : Transform;
var end : Transform;

function Update () {
transform.position = Vector3.Lerp (transform.position,end.position,Time.time);
}

``````

I'm assuming I would be using an if state, maybe something like: If(GameObject is here) {move it here}

That's just an un-educated guess though.

UPDATE**

Okay I made a collision script, and though I get no errors it doesn't seam to do anything. My objects have rigid bodies but no colliders, here's the script.

`````` var start : Transform;
var end : Transform;
var end2 : Transform;

function Update () {
transform.position = Vector3.Lerp (transform.position,end.position,Time.time);

}

function OnCollisionEnter(collision : Collision) {
if(collision.gameObject.name == "hit")
transform.position = Vector3.Lerp (transform.position, end2.position,Time.time);

}

``````

Try Lerping from the "start" position you set up instead of the transform.position you have in code now.

** Update **

Apologies. I think I know what you mean now, you're wanting to queue the action of movement. Unless you have some other system determining your "next" position, I would think the easiest way would be to have a script that checks for the moving object to collide with it, then has a moveTo property (Vector3 or GameObject) assigned to it that indicates where to move next. Then place a movement script on the moving object to check against whether your current position is where you're supposed to be; if not, Lerp to it.

try this script:

``````transform.localPosition.x = other.localPosition.x;

``````

or you also can use this one if you want the entire object:

``````transform.position = other.position;

``````

and if you want to do it for some time you use Time.deltaTime * speed;