How can a gameobject follow the last gameobject in a chain?

I’m trying to get a gameobject to follow another gameobject, without being parented so the following object can get lost, and separated from the primary gameobject. I had a very rough follow without damping, and it never looked very good. I’d like to improve and fix that. My goal is to get multiple gameobjects following eachother in a loose chain.

moveForward = transform.forward * basicSpeed * Time.deltaTime;
	
Quaternion rotationChange = Quaternion.LookRotation(followPos - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotationChange, 6f * Time.deltaTime);
transform.Translate(moveForward);

This should give you the results you’re looking for it’s in UnityScript so I hope that’s ok:

var follow : GameObject;
var xOffset : int;
var yOffset : int;
var zOffset : int;

function FixedUpdate () 
{
	transform.position = Vector3(Mathf.Lerp(transform.position.x, follow.transform.position.x + xOffset, Time.deltaTime),Mathf.Lerp(transform.position.y, follow.transform.position.y + yOffset, Time.deltaTime),Mathf.Lerp(transform.position.z, follow.transform.position.z + zOffset, Time.deltaTime));
}

Just add the script onto all of the following objects and drag and drop the object it should follow into the follow variable.

Then you can change the offset so that the object stays a certain distance behind the object it’s following.

Hope this helps :slight_smile:

Edited to fixedupdate

Can you just decrease the basicSpeed to be slower for the following object? You can use iTween to set a speed as well and follow them, but just set the speed to a realistic speed that the object being chased can outrun.