M MY Multiplayer: Wiki
Side
Kind

interpolateBetween

Shared

Interpolates between two sets of three numbers along an easing curve.

float, float, float interpolateBetween(float x1, y1, z1, float x2, y2, z2, float progress, string easingType [, float easingPeriod = 0.3, float easingAmplitude = 1, float easingOvershoot = 1.70158])

Parameters

NameTypeDescription
x1, y1, z1floatThe starting values. A vec3 also works.
x2, y2, z2floatThe target values. A vec3 also works.
progressfloatThe progress, from 0 to 1.
easingTypestringThe easing curve, such as "Linear", "InOutQuad", "OutBounce" or "SineCurve".
easingPeriodfloatThe period of the elastic curves.default 0.3
easingAmplitudefloatThe amplitude of the elastic and bounce curves.default 1
easingOvershootfloatHow far the Back curves overshoot the target.default 1.70158

Returns

The three interpolated numbers. With progress at 1 or more, they are exactly the target ones when the curve ends there.

Example

local start = getTickCount()
addEventHandler("onClientRender", root, function()
    local progress = math.min((getTickCount() - start) / 2000, 1)
    local x, y = interpolateBetween(0, 0, 0, 400, 300, 0, progress, "InOutQuad")
    dxDrawText("Hello", x, y)
end)

See also