Recently I’ve come across a puzzle which involves lerping numbers. Let’s put this into your imagination: A value is used to determine the speed of an animation, when the value reaches 1, it reaches it’s maximum speed, and if the value reaches 0, it completely stops. But in this case, what if you had a click detector that did this? What if you clicked while it was interpolating the value? Wouldn’t it start from either one or zero? Why not the current value (aka the current time position) it’s at and then to one or zero?
Think of this like TweenService. When another tween overrides the previous tween (in this case for the value), it starts where it left off at, and returns to either zero or one with correct easing.
How would you do this? I already understand 1 - alpha
, but changing 1 to the current value may lead to negative numbers if alpha
is above 1. Sure, I could clamp the values but it doesn’t seem as effective, what if you are using custom easing? It’ll look out of place.
Sorry if this doesn’t make any sense to you, It’s 02:18. In essence, I want to know how to lerp a value from it’s current value to either 0 or 1, instead of completely restarting.