transforming position

I’m trying to transform the position of an object once a variable in another script becomes true, but of course, it doesn’t work properly, it starts from position B once the variable (csScript.wave) becomes true. Here is my code;

    var pointB : Vector3;
    var pointC : Vector3;
    var pointD : Vector3;
    var pointE : Vector3;
    var pointF : Vector3;
    var csScript : TargetCollision;
    // private var endPos : Vector3 = new Vector3(0.0, 40.0, 0.0);
    function Start () {
    
 //animation.Play("running"); 
    var pointA = transform.position;
    while (true) {
   //while(csScript.wave){
//if(csScript.wave){
    yield MoveObject(transform, pointA, pointB, 3.0);
    yield MoveObject(transform, pointB, pointC, 3.0);
    yield MoveObject(transform, pointC, pointD, 3.0);
    yield MoveObject(transform, pointD, pointE, 3.0);
    yield MoveObject(transform, pointE, pointF, 3.0);
   // }
    }
    }
     
    function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3 , time : float) {
     if(csScript.wave){
        transform.position = startPos;
    transform.LookAt(endPos);
    var i = 0.0;
    var rate = 1.0/time;
    while (i < 1.0) {
    i += Time.deltaTime * rate/8;
    // if(csScript.wave)
    thisTransform.position = Vector3.Lerp(startPos, endPos, i);
    yield;
    }
     }
     
    }

pull your “while(true)” conditional code out of start() and whack into Update()… it is only running the code once and consequently only moving it a single time (3 units per frame/second).
After that the code is never called again.
Why?
Because Start() is an initialisation method.
update is the game loop, this is where code will be read over and over again.

BTW, what is a MoveObject, something I have never heard of outside of bespoke code for Unity.
Normally, you call to transform.Translate(); feeding the argument with vector positions and float distance…like so…

transform.translate(this.transform.position, objectToMoveTo.transform.position, 3.0f );

Your objectToMoveTo would be another GameObject/Transform that you have specified (perhap as a public GameObject in your script that you could assign in the inspector to the script etc.
just comment and I will get back to you if not, else if it answered your question help others to find it too by marking it an answer.

there is another way, a better way…
LERP

This allows something known as linear interpolation between to specified objects and a float value for the length of time to take getting from one point to another. Check out the reference above, it is the way forward for you, with respect to better handling of your transforms translations (at this point anyway)

take care bud.

Gruffy.