This function will return a struct containing all the data for the given animation curve. You supply the animation curve asset ID (as defined in the Asset Browser), and the function will return a struct with the following variables:
| Variable Name | Data Type | Description |
|---|---|---|
| name | string | This is the name of the animation curve. |
| channels | array pointer | This is an array, where each item in the array is a channel struct. |
When accessing an animation curve in this way, you get an array back where each array item is a struct with data relating to a channel within the curve. The channel struct will have the following
variables:
| Variable Name | Data Type | Description |
|---|---|---|
| name | string | This is the name of the channel. |
| type | constant | This will be one of the constants animcurvetype_linear for linear interpolation between points, or animcurvetype_catmullrom for "smooth" interpolation between the points using catmull-rom interpolation. |
| iterations | integer | If the channel is using catmull-rom ("smooth") interpolation this holds how many points have been generated for each segment of the curve (note that these extra points are internal to the function and only used for the runtime calculations). If the channel is using linear interpolation, this value will still exist but can be ignored as it has no bearing on how the curve is interpolated. |
| points | array pointer | This is an array, where each item in the array is a point struct. |
As with channels, the points on a single channel are stored as structs in an array, where each item in the array is a single point struct. The point struct has the following variables:
| Variable Name | Data Type | Description |
|---|---|---|
| posx | real | The position in time (normalised from 0 to 1) of the point. |
| value | real | The value of the point. |
Note that if the function fails (ie: the given Animation Curve ID does not exist) then the function will return -1.
animcurve_get(curve_id);
| Argument | Description |
|---|---|
| curve_id | The asset browser ID (index) of the animation curve to get. |
Struct or -1
var _curve = animcurve_get(ac_ButtonTween);
var _channel = _curve.channels[0];
if _channel.type != animcurvetype_linear
{
_channel.type = animcurvetype_linear;
}
The above code retrieves the animation curve struct for the curve asset "ac_ButtonTween", then checks the curve type for the first channel, and if it's not linear it sets it to linear.