What is the best way to smoothly update a float?

Perhaps write your own function to do this?

ie Create a variable (float) named updateRate and another (float) targetValue.
Create a function SetNewTargetValue (with two inputs NewValue(float) and Time(float)). Within the function, set

targetValue = newValue

updateRate = (NewValue-Currentvalue)/Time

In the Tick event, do this:
CurrentValue = min(CurrentValue+(updateRate*deltaDeconds), targetValue)

You will do the above only if (updateRate != 0 AND CurerntValue != targetValue)

I think this will give you a linear increase.

1 Like