Contains data used to animate everything in the engine.
    public class Animation : Resource

An Animation resource contains data used to animate everything in the engine. Animations are divided into tracks, and each track must be linked to a node. The state of that node can be changed through time, by adding timed keys (events) to the track.

[codeblock]

This creates an animation that makes the node “Enemy” move to the right by

100 pixels in 1 second.

var animation = Animation.new()

var track_index = animation.add_track(Animation.TYPE_VALUE)

animation.track_set_path(track_index, “Enemy:position.x”)

animation.track_insert_key(track_index, 0.0, 0)

animation.track_insert_key(track_index, 0.5, 100)

[/codeblock]

Animations are just data containers, and must be added to nodes such as an AnimationPlayer or AnimationTreePlayer to be played back.

Inheritance Chain

Constructors

    public Animation()

Signals

    "tracks_changed" ()

Properties

    public float Length { get; set; }

The total length of the animation (in seconds). Note that length is not delimited by the last key, as this one may be before or after the end to ensure correct interpolation and looping.

    public bool Loop { get; set; }

A flag indicating that the animation must loop. This is uses for correct interpolation of animation cycles, and for hinting the player that it must restart the animation.

    public float Step { get; set; }

The animation step value.

Methods

    public int AddTrack(TrackType type, int atPosition = -1)

Add a track to the Animation. The track type must be specified as any of the values in the TYPE_* enumeration.

    public string AnimationTrackGetKeyAnimation(int idx, int keyIdx)

    public int AnimationTrackInsertKey(int track, float time, string animation)

    public void AnimationTrackSetKeyAnimation(int idx, int keyIdx, string animation)

    public float AudioTrackGetKeyEndOffset(int idx, int keyIdx)

    public float AudioTrackGetKeyStartOffset(int idx, int keyIdx)

    public Resource AudioTrackGetKeyStream(int idx, int keyIdx)

    public int AudioTrackInsertKey(int track, float time, Resource stream, float startOffset = 0f, float endOffset = 0f)

    public void AudioTrackSetKeyEndOffset(int idx, int keyIdx, float offset)

    public void AudioTrackSetKeyStartOffset(int idx, int keyIdx, float offset)

    public void AudioTrackSetKeyStream(int idx, int keyIdx, Resource stream)

    public Vector2 BezierTrackGetKeyInHandle(int idx, int keyIdx)

    public Vector2 BezierTrackGetKeyOutHandle(int idx, int keyIdx)

    public float BezierTrackGetKeyValue(int idx, int keyIdx)

    public int BezierTrackInsertKey(int track, float time, float value, Vector2? inHandle = default(Vector2?), Vector2? outHandle = default(Vector2?))

    public float BezierTrackInterpolate(int track, float time)

    public void BezierTrackSetKeyInHandle(int idx, int keyIdx, Vector2 inHandle)

    public void BezierTrackSetKeyOutHandle(int idx, int keyIdx, Vector2 outHandle)

    public void BezierTrackSetKeyValue(int idx, int keyIdx, float value)

    public void Clear()

Clear the animation (clear all tracks and reset all).

    public void CopyTrack(int track, Animation toAnimation)

Adds a new track that is a copy of the given track from toAnimation.

    public int FindTrack(NodePath path)

Return the index of the specified track. If the track is not found, return -1.

    public float GetLength()

Getter for Length

    public float GetStep()

Getter for Step

    public int GetTrackCount()

Return the amount of tracks in the animation.

    public bool HasLoop()

Getter for Loop

    public int[] MethodTrackGetKeyIndices(int idx, float timeSec, float delta)

Return all the key indices of a method track, given a position and delta time.

    public string MethodTrackGetName(int idx, int keyIdx)

Return the method name of a method track.

    public Godot.Collections.Array MethodTrackGetParams(int idx, int keyIdx)

Return the arguments values to be called on a method track for a given key in a given track.

    public void RemoveTrack(int idx)

Remove a track by specifying the track index.

    public void SetLength(float timeSec)

Setter for Length

    public void SetLoop(bool enabled)

Setter for Loop

    public void SetStep(float sizeSec)

Setter for Step

    public int TrackFindKey(int idx, float time, bool exact = false)

Find the key index by time in a given track. Optionally, only find it if the exact time is given.

    public bool TrackGetInterpolationLoopWrap(int idx)

Returns true if the track at idx wraps the interpolation loop. Default value: true.

    public InterpolationType TrackGetInterpolationType(int idx)

Return the interpolation type of a given track, from the INTERPOLATION_* enum.

    public int TrackGetKeyCount(int idx)

Return the amount of keys in a given track.

    public float TrackGetKeyTime(int idx, int keyIdx)

Return the time at which the key is located.

    public float TrackGetKeyTransition(int idx, int keyIdx)

Return the transition curve (easing) for a specific key (see built-in math function “ease”).

    public object TrackGetKeyValue(int idx, int keyIdx)

Return the value of a given key in a given track.

    public NodePath TrackGetPath(int idx)

Get the path of a track. for more information on the path format, see TrackSetPath(int, Godot.NodePath)

    public TrackType TrackGetType(int idx)

Get the type of a track.

    public void TrackInsertKey(int idx, float time, object key, float transition = 1f)

Insert a generic key in a given track.

    public bool TrackIsEnabled(int idx)

Returns true if the track at index idx is enabled.

    public bool TrackIsImported(int idx)

Return true if the given track is imported. Else, return false.

    public void TrackMoveDown(int idx)

Move a track down.

    public void TrackMoveUp(int idx)

Move a track up.

    public void TrackRemoveKey(int idx, int keyIdx)

Remove a key by index in a given track.

    public void TrackRemoveKeyAtPosition(int idx, float position)

Remove a key by position (seconds) in a given track.

    public void TrackSetEnabled(int idx, bool enabled)

Enables/disables the given track. Tracks are enabled by default.

    public void TrackSetImported(int idx, bool imported)

Set the given track as imported or not.

    public void TrackSetInterpolationLoopWrap(int idx, bool interpolation)

If true, the track at idx wraps the interpolation loop.

    public void TrackSetInterpolationType(int idx, InterpolationType interpolation)

Set the interpolation type of a given track, from the INTERPOLATION_* enum.

    public void TrackSetKeyTransition(int idx, int keyIdx, float transition)

Set the transition curve (easing) for a specific key (see built-in math function “ease”).

    public void TrackSetKeyValue(int idx, int key, object value)

Set the value of an existing key.

    public void TrackSetPath(int idx, NodePath path)

Set the path of a track. Paths must be valid scene-tree paths to a node, and must be specified starting from the parent node of the node that will reproduce the animation. Tracks that control properties or bones must append their name after the path, separated by “:”.

Example: “character/skeleton:ankle” or “character/mesh:transform/local”.

    public void TrackSwap(int idx, int withIdx)

    public int TransformTrackInsertKey(int idx, float time, Vector3 location, Quat rotation, Vector3 scale)

Insert a transform key for a transform track.

    public Godot.Collections.Array TransformTrackInterpolate(int idx, float timeSec)

Return the interpolated value of a transform track at a given time (in seconds). An array consisting of 3 elements: position (Vector3), rotation (Quat) and scale (Vector3).

    public int[] ValueTrackGetKeyIndices(int idx, float timeSec, float delta)

Return all the key indices of a value track, given a position and delta time.

    public UpdateMode ValueTrackGetUpdateMode(int idx)

Return the update mode of a value track.

    public void ValueTrackSetUpdateMode(int idx, UpdateMode mode)

Set the update mode (UPDATE_*) of a value track.

Inner Types

InterpolationType

Name Value Description
Nearest 0 No interpolation (nearest value).
Linear 1 Linear interpolation.
Cubic 2 Cubic interpolation.

TrackType

Name Value Description
Value 0 Value tracks set values in node properties, but only those which can be Interpolated.
Transform 1 Transform tracks are used to change node local transforms or skeleton pose bones. Transitions are Interpolated.
Method 2 Method tracks call functions with given arguments per key.
Bezier 3  
Audio 4  
Animation 5  

UpdateMode

Name Value Description
Continuous 0 Update between keyframes.
Discrete 1 Update at the keyframes and hold the value.
Trigger 2 Update at the keyframes.
Capture 3  
Tags: