# How do i repeat the Lerp movement?

**URL:** https://discussions.unity.com/t/how-do-i-repeat-the-lerp-movement/70015
**Category:** Questions & Answers
**Created:** [May 2, 2013, 11:16pm UTC](https://discussions.unity.com/t/how-do-i-repeat-the-lerp-movement/70015 "2013-05-02T23:16:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![inglipX](https://avatars.discourse-cdn.com/v4/letter/i/a9a28c/32.png) [@inglipX](https://discussions.unity.com/u/inglipX)
#### Post date: [May 2, 2013, 11:16pm UTC](https://discussions.unity.com/t/how-do-i-repeat-the-lerp-movement/70015/1 "2013-05-02T23:16:57Z")

</div>

I have a script that says when i hit pointA, lerp to pointB. It works great but when I go back to point A it wont repeat the lerp movement. Additionally, how would i set the Vector3 position to an actual gameobject, my pointA and pointB?

```
var pointA:Vector3;
var pointB:Vector3;
var time:float = 10.0;
var i:float = 0.0;
private var rate:float = 0.0;
var detector : ClimbDetectionScript;
var pointAobject : GameObject;
var pointBobject : GameObject;

function Update () 
{   
   MoveObject(this.transform, pointA, pointB, time);
   
}

function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) 
{
   rate = 1.0/time;
   if (i < 1.0)
	if (detector.startSpot == true)
   {
       i += Time.deltaTime * rate;
       thisTransform.position = Vector3.Lerp(startPos, endPos, i);
       
       

       
   }
}

```

---

<div class="post-metadata">

### Author: ![SubatomicHero](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@SubatomicHero](https://discussions.unity.com/u/SubatomicHero)
#### Post date: [May 3, 2013, 8:10am UTC](https://discussions.unity.com/t/how-do-i-repeat-the-lerp-movement/70015/2 "2013-05-03T08:10:36Z")

</div>

Potential answer to your first question:

After the movement is done, maybe reassign i=0???

Can you re ask the second question please…I’m not quite understanding what your asking. You can get the Vector3 position of any gameobject in the scene as long as you have a reference to it.

Vector3 pointA = pointAObject.transform.position;
