- Home /
Duplicate Question
Lerp stopping/not working?
I'm trying to lerp a value but the lerp just suddenly stops.
void FixedUpdate() {
globalSpeed = Mathf.Lerp(6, 20, Time.fixedDeltaTime * 1f);
playerCarBehaviour.speed = globalSpeed;
}
speed goes to 6.28 and then it just stops and stays on there forever, how come?
Answer by hav_ngs_ru · Mar 10, 2015 at 11:04 AM
Mathf.Lerp(fromValue, toValue, factor), where factor is between 0 and 1
it will return fromValue + (toValue - fromValue) * factor
if factor = 0 it will return fromValue (the begining of lerp)
if factor = 1 it will return toValue (the end of lerp)
when factor is between 0 and 1 - it will return some value between fromValue and toValue.
if factor is changing - lerp is changing, if factor is constant - lerp will return the same value every call.
fixedDeltaTime is constant (I even guess the value of fixedDeltaTime is 0.28 in your case)...
do you need more hints? :)