# Easing

Easing functions describe functions that control the way an interpolation between 0 and 1 is done.

The most basic easing function, linear, is just a linear interpolation at constant speed. Other more advanced easing functions can have acceleration at the beginning, the end or both or deceleration, or even bouncing or elastic effects.

# Preliminary note

In the functions using easing, there are usually 3 optional parameters. Most functions don't need them at all, the ones needing one or more parameters are listed in the table below. When providing optional parameters, all the parameters before a given parameter must be filled, even if the easing function you intend to use doesn't require such a parameter. In this case, simply use 0 for the parameters you don't need. Examples:

• "Linear" can be used simply with getEasingValue( fProgress, "Linear" )
• "OutElastic" can define fEasingPeriod and fEasingAmplitude so it can be used with getEasingValue( fProgress, "OutElastic", 0.3, 1.0 )
• "InBack" can define fEasingOvershoot, but since it comes after fEasingPeriod and fEasingAmplitude in the order of parameters, 0 must be used for the others with getEasingValue( fProgress, "InBack", 0, 0, 1.7015 )

# Easing functions

```--List of builtin easing functions
```

Default values are (when a function can use a parameter but it's not defined by the user):

• fEasingPeriod: 0.3
• fEasingAmplitude : 1.0
• fEasingOvershoot: 1.701
Easing function Function profile Uses fEasingPeriod Uses fEasingAmplitude Uses fEasingOvershoot Comments
Linear
InElastic yesyesDue to the elastic effect, this easing function produces some values < 0
OutElastic yesyesDue to the elastic effect, this easing function produces some values > 1
InOutElastic yesyesDue to the elastic effect, this easing function produces some values < 0 and > 1
OutInElastic yesyesDue to the elastic effect, this easing function produces some values < 0 and > 1
InBack yesDue to overshoot, this easing function produces some values < 0
OutBack yesDue to overshoot, this easing function produces some values > 1
InOutBack yesDue to overshoot, this easing function produces some values <0 and > 1
OutInBack yes
InBounce yes
OutBounce yes
InOutBounce yes
OutInBounce yes
SineCurve This easing function doesn't end at 1 but goes back to 0. In this case, for interpolation, the target value is just an edge but doesn't represent the stop value.
CosineCurve This easing function both starts and stops at 0.5, going first to 1 then 0. In this case, for interpolation, the source and target values are just the edges but don't represent the start/stop values.

## Examples

Click to collapse [-]

Example 1: This example move gate with easing.

```local x,y,z = 2096.3, 1721, 12.7
local easing = "OutBounce"
local time = 2000
local gate = createObject(980, x,y,z, 0, 0, 63)
local marker = createMarker(x,y,z, "cylinder", 12, 0, 0, 0, 0)

function moveGate(hitPlayer, matchingDimension)
moveObject(gate, time, x+4.9, y+9.6, z, 0, 0, 0, easing)
end