Lerp for a precise timespan ?

Hello there !

I juste have a simple question to ask : is it possible to Lerp something during a precise timespan like 1 second, 0.65 second and so on ? (That is to say that the interpolation would be over after that time span)

Thanks in advance for your answers :slight_smile:

C# code:

float start;
float end;
float valueToLerp;

float duration = 0.65f;
for (float t=0.0f; t<duration; t+=Time.deltaTime) {			
   valueToLerp = Mathf.Lerp(start, end, t/duration);    			
   yield return null;
}
valueToLerp = end;

This will lerp your value from start to end over duration seconds. Wrap it in a function and use it with StartCoroutine()