# LERP gives final value way too early

Hi people,
I hope someone could help me with my problem. I use the following coroutine to interpolate my main camera from one place to another. Everything works OK except the fact that the two LERP functions reach the final value when fraction is still like 0.2, and from 0.2 to 1.0 they keep returning the final value… I just cannot understand where’s the mistake…

``````private IEnumerator tweenCameraToPosition(Vector3 finalPosition, Quaternion finalRotation, float seconds, System.Action callback)
{

float elapsedTime = 0;
Transform startTr = this.gm.getCharacterTransform();
Vector3 currPosition;
Quaternion currRotation;

while (elapsedTime < seconds)
{
float fraction=elapsedTime/seconds;

currPosition=Vector3.Lerp(startTr.position,finalPosition,fraction);
currRotation=Quaternion.Lerp(startTr.rotation,finalRotation,fraction);
elapsedTime += Time.deltaTime;
this.gm.moveCharacterTo(currPosition,currRotation);
yield return null;
}
if (callback != null) {
callback();
}
}
``````

I assume this is because you lerp from camera’s current position, not from start position. Try this:

``````Transform startTr = this.gm.getCharacterTransform();
// Save camera's start position
Vector3 startPosition = startTr.position;
...
// And lerp from it
currPosition = Vector3.Lerp(startPosition,finalPosition,fraction);
``````

It could be because Vector3.Lerp used a value t which is clamped between 0 and 1:

Vector3.Lerp

So if in your script the fraction value reaches 1 it means the Lerp is complete.