Lerp can be used for various things. See [[mathf.getValueInRangeByProgress]]
which is an alias of lerp.
Lerp can also be used for animations. If you were doing the old school:
onRafLoop() { // Update the position by 20% of the distance between position and target. position.x += (target.x - position.x) * 0.2; }
this can be replaced with:
onRafLoop() { // Same thing. Update the position by 20% of the distance between // position and target on each raf loop. This has the effect of // tweening in the position to the target. position.x = mathf.lerp(position.x, target.x, 0.2); }
Parameters
value1: number
The start of the range to lerp.
value2: number
The target of the range to lerp.
amount: number
A value between 0-1 representing the progress of the
lerp.
Linear interpolate from start to end given amount.
Lerp can be used for various things. See [[mathf.getValueInRangeByProgress]] which is an alias of lerp.
Lerp can also be used for animations. If you were doing the old school:
this can be replaced with: