Skip to main content

Mathf.MoveTowards(number current, number target, number maxDelta)

Moves a value current towards target.

Parameters:

NameTypeDescription
currentnumberThe current value.
targetnumberThe value to move towards.
maxDeltanumberThe maximum change that should be applied to the value.

Returns:

typeDescription
numberMoved value current towards target.

Usage

---@type number
local current;

---@type number
local target;

---@type number
local maxDelta;


local val0 = Mathf:MoveTowards(current, target, maxDelta)

Extra Detail

This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. Negative values of maxDelta pushes the value away from target.