smoothDamp

fun smoothDamp(p: Double, q: Double, velocity: Double, deltaTime: Double? = definedExternally, maximumSpeed: Double? = definedExternally, smoothTime: Double? = definedExternally, result: Math.SmoothDampResult? = definedExternally): Math.SmoothDampResult(source)

Gradually changes a value towards a target value over time. The smoothing function uses a spring-damping algorithm based on Game Programming Gems 4 Chapter 1.10.

Return

An object containing the new value and the updated current velocity.

Parameters

p

The current value.

q

The target value.

velocity

The current velocity.

deltaTime

The time since the last call to this function. Value must be greater than or equal to 0.0. Default value - 0.0

maximumSpeed

Optionally allows clamping to the specified maximum speed. Default value - Number.POSITIVE_INFINITY

smoothTime

Approximately the time it will take to reach the target. A smaller value will reach the target faster. This value must be greater than or equal to 0.0001. Default value - 0.0001

result

An object to store the result. If not provided, a new object will be created and returned.

See also