Motion
Get Motion

ReferenceScripting APIMotionMathsdamp

MotionMaths.damp

method

A value followed toward a target, the same whatever the frame rate.

Namedamp
Kindmethod of MotionMaths
Called asmaths.damp(…)
As a nodeSmooth Follow (logic graph)
Since0.4

Syntax

damp(    current: number,    target: number,    smoothing: number,    dt: number): number

Parameters

NameTypeDescription
currentnumberWhere it is
targetnumberWhere it's going
smoothingnumberSeconds it takes to get most of the way (about 63%)
dtnumberSeconds since the last time (tick's dt)

Returns

number: where it is now.

Example

let level = 0;scene.on("tick", (time, dt) => { level = scene.maths.damp(level, scene.audio.level, 0.3, dt); });