float moveDistance = 0;
while ( Vector3.Distance(transform.position, player.position) > 2)
{
transform.position = Vector3.MoveTowards(transform.position, player.position, moveDistance);
moveDistance += Time.deltaTime * followSpeed;
yield return null;
}
This works for a couple seconds, then it instantly teleports to the players position. I put log statements all over my code and it seems like moveDistance is going up to 9 and then stopping, then when this code happens again moveDistance starts at a normal number, then instantly goes to 9 the next frame. I’m really confused about this one.