|real||The starting value to interpolate from|
|real||The target value to interpolate to|
|real||The amount, or percentage to interpolate between values (variable recommended)|
|integer/macro||Sets the easing method for the interpolation (see options below)|
|real||Optional: X percentage for left control point of a cubic bezier curve (0-1)|
|real||Optional: Y percentage for left control point of a cubic bezier curve (0-1)|
|real||Optional: X percentage for right control point of a cubic bezier curve (0-1)|
|real||Optional: Y percentage for right control point of a cubic bezier curve (0-1)|
|curve||Optional: Animation curve asset to use if |
Returns a value interpolated between the two input values with optional easing methods to create a smooth start and/or end to animations.
The first input value should equal the original state of the value and the second input the target state of the value. For example, to move an object from
x = 0 to
x = 50,
50 would be the two input values here.
The third input value can be thought of as a percentage of completion. Using the same example, an input amount of
0.5 would return
x = 25.
In order to create animations with this script, the interpolation amount must be input as a variable which is incremented externally.
The fourth and final value is an integer specifying the easing method used during interpolation. Simple
false values can be used here for sine or linear interpolation, respectively, but in addition to these basic modes there are 30 different easing techniques, plus other custom techniques, featured below. Built-in easing techniques are ordered from shallowest to deepest curve.
See the included interactive demo for a visual example of this function!
For memorability, it is recommended to use an easing macro from the list below in place of an integer value:
|Easing Macro||Value||Easing Macro||Value|
If the bezier ease mode is selected, four more arguments can be supplied to act as control points for a custom interpolation curve. These values range from 0-1, but Y values can be less or greater to create a rubber-banding effect. See https://cubic-bezier.com/ for an interactive visual example.
Other types of curves can be created visually in GameMaker 2.3 and newer. To use these curves with
ease_curve as the mode and then supply an additional argument pointing to the animation curve asset desired. Note that only the first channel in an animation curve asset will be used.
Only a custom bezier curve or a custom curve asset can be input. Both cannot be input at the same time.