Delay on Moving Platform

Hi. I’m trying to add a delay to my moving platform script. It does delay, but then it synchs up with the other prefabs.

static var Waypoint : boolean = true;
var pointB : Transform;
private var pointA : Vector3;
var speed = 1.0;
var delay = 0;
        
function Start () {

  	yield WaitForSeconds(delay);
    	    
    if(Waypoint == true) {

            pointA = transform.position;

            while (true) {

            var i = Mathf.PingPong(Time.time * speed, 1);

            transform.position = Vector3.Lerp(pointA, pointB.position, i);

            yield;
            }
       }
}

I’m currently not on my PC so I can’t try if im right.

You could try to replace Time.time by a variable! (Time.time is the time since the game has started. It does not stop with the delay!

static var Waypoint : boolean = true;
var pointB : Transform;
private var pointA : Vector3;
var speed = 1.0;
var delay = 0;

private var localTime = 0.0;

function Start () {

    yield WaitForSeconds(delay);

    if(Waypoint == true) {

            pointA = transform.position;

            while (true) {

            localTime += Time.deltaTime;

            var i = Mathf.PingPong(localTime * speed, 1);

            transform.position = Vector3.Lerp(pointA, pointB.position, i);

            yield;
            }
       }
}