Lerping a float?

Hi,

is there a way to “lerp” the value of a variable (float or int) from the current value to another value over for, lets say, 0.5 seconds? I tried the Mathf.Lerp function but it doesnt seem to be intended for this kind of thing?

Thanks/ Robin

You can lerp anything. Just use Time.time as the third param, or any kind of variable altered by Time.deltaTime.

Just like here

The third parameter is a value between 0 and 1, so just use timePassed/totalTime (where total time is 0.5)

It’s 100% exactly for that kind of thing.

No, not Time.time. I know the doc example uses it, but it’s more or less wrong. The third parameter is a float between 0 and 1, so just make it go from 0 to 1 over .5 seconds.

–Eric