So I have a code that makes a friend follow you on command but the problem is, even though he has the exact same speed as the player he moves faster. Whats the deal?
disFromLeader = Vector3.Distance(current.position, transform.position);
if(disFromLeader > 8)
{
var targetPoint = current.transform.position;
var targetRotation = Quaternion.LookRotation(targetPoint - transform.position, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.0);
transform.position += transform.forward * moveSpeed * Time.deltaTime;
}
He has the exact same speed as the player but if I stand far away the guy will move super fast to get to me then when he’s within 8m of me he slows down.
In actual fact I have no idea how to make a good code where more than one person can follow you and make it look natural. With my current code they’ll all stay like 8m away and collide and stuff, any ideas?