How can I limit the distance of my object ?

The code work, but the position always is restarted to zero.

```
horizontal = horizontal * (movimento * Time.deltaTime);
vertical = vertical * (movimento * Time.deltaTime);
Vector3 fwd = new Vector3(horizontal * -1f, 0f, vertical * -1f);
if (fwd != Vector3.zero)
{
parabola.endPosition.forward = fwd;
}
Vector3 rot = new Vector3(horizontal, 0f, vertical);
if (rot != Vector3.zero)
{
parabola.endPosition.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(rot), 10f * Time.deltaTime);
parabola.endPosition.Translate(horizontal * -10f, 0f, vertical * -10f, Space.World);
}
float dist = Vector3.Distance(parabola.startPosition.localPosition, parabola.endPosition.localPosition);
if (dist > parabola.maxDistance)
{
Vector3 newpos = parabola.endPosition.localPosition - parabola.startPosition.localPosition;
newpos = newpos.normalized;
newpos *= (dist - parabola.maxDistance);
parabola.endPosition.localPosition = newpos;
}
```

When I change the position of endPosition using **parabola.endPosition.localPosition = newpos;** the code not work.