Juddering object movement

I have the code here http://www.pasteit4me.com/788001

Which moves an object though an array, the object will move along the array and line ok but it will judder and go slow and fast. What i want is the object to move smoothly along the array without suddenly speeding it up.

Any help appreciated :slight_smile:

To get smooth movement, you need to lerp between a fixed start and end position and the amount of time you take for the full lerp should be proportional to the length of the current leg of the path. I’ve attached a script with a class that handles this. There are a few different ways you can use it, but you might do something roughly like the following:-

var path: Vector3[];
var marker: Transform;
var speed: float;

private var pf: PathFollower;


function Start() {
	pf = new PathFollower(path, speed);
}


function Update () {
	marker.position = pf.Position();
	marker.rotation = Quaternion.LookRotation(pf.Direction());
}


function OnDrawGizmos() {
	if (path.Length < 2) {
		return;
	}
	
	var prevPt = path[0];
	
	for (i = 1; i < path.Length; i++) {
		var currPt = path[i];
		Gizmos.DrawLine(prevPt, currPt);
		prevPt = currPt;
	}
}

335292–11772–$pathfollower_182.js (1.32 KB)