Hi there,
I am using this code to move a transform along a spline. I want to add in a ping pong feature, so the object will bounce back and forth between the beginning and end. I think I should use Mathf.PingPong but am unsure where to apply it.
// Make the cube "ride" the spline at a constant speed
do {
for (var dist = 0.0; dist < 1.0; dist += Time.deltaTime*speed) {
var splinePoint = splineLine.GetPoint01 (dist);
cube.position = Camera.main.ScreenToWorldPoint (Vector3(splinePoint.x, splinePoint.y, 10.0));
yield;
}
} while (loop);
}