- Home /
Movement in cycles?
If I use this code in two obstacles, one with the delay and without it, the delayed one seems to teleport so it has the same value on the x-axis with the other one. Any idea why this happens?
#pragma strict
var speed = 5f;
var delay = 1f;
var pos1 = 1;
var pos2 = 4.9;
function Start () {
Invoke ("Move", delay);
}
function Move (){
transform.position = new Vector3(pos1 + Mathf.PingPong(Time.time * speed, pos2), transform.position.y, transform.position.z);
Invoke ("Move", 0);
}
Comment