[Unit Move | GameDev.tv](Unit Move - CodeMonkey)
Here’s an alternative that doesn’t need the ‘magic number’ at all and always stops at the target position.
Vector3 toTarget = targetPosition - transform.position;
float dist = toTarget.magnitude;
if (dist > 0)
{
Vector3 move = toTarget.normalized * moveSpeed * Time.deltaTime;
// if we're going to overshoot the target
if (move.magnitude > dist)
{
// move exactly to target location
move = toTarget;
}
transform.position += move;
}