Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///@func lerp_curb(val1, val2, amount, limit)
- ///@desc Returnes a lerp'ed result which is cut off at a certain value.
- /// Can be useful to avoid lerp() taking long to reach target value because of decay.
- ///
- ///@param val1 Starting value
- ///@param val2 Target value
- ///@param step Step (0 - 1)
- ///@param limit Value at which the lerp is cut off (returning target value)
- var _start, _end, _step, _limit, _output;
- //Init arguments
- _start = argument0;
- _end = argument1;
- _step = argument2;
- _limit = argument3;
- //Lerp
- _output = lerp(_start, _end, _step);
- //If lerped value is beyond limit value, return target value
- return (abs(_end - _output) <= abs(_end - _limit)) ? _end : _output;
Advertisement
Add Comment
Please, Sign In to add comment