Vector3.Lerp bug? : <p><strong>I know how to move GameObject over time, but I have a weird bug.</strong></p>

<p>I am trying to create nice animation where the camera moves forward on button click and backward on second button click.</p>

<p>I am using the code from <a href="https://chicounity3d.wordpress.com/2014/05/23/how-to-lerp-like-a-pro/" rel="nofollow noreferrer">here</a> to do the animation and have a weird problem.</p>

<p>This is my code:</p>

<pre><code>private float time = 5, current;
public void MoveBackward()
{
   StartCotoutine(MoveTo(Vector3.zero));
}

public void MoveForward()
{
   StartCotoutine(MoveTo(new Vector3(0,0,15)));
}
private IEnumerator MoveTo(Vector3 target)
{
   current=0;
   while(transform.position!=target)
   {
     transform.position = Vector3.Lerp(transform.position, target, current/time);
     current = Mathf.Clamp(current+Time.deltaTime,0,time);
     yield return null;
   }
}
</code></pre>

<p><strong>The forward motion works good, but for some reason when I try to move backwards it moves too fast. I tried to print the result (current/time) and in the backwards movement it is 0.1 (approximately) when the transform reaches to the destination.</strong></p>

<p>P.S. - I am running another <code>Cotoutine</code> in the background (if it matters)</p>

<p>Do you know why it happens¿</p>

<p>Thanks in advance</p>
