Struct Animation

Contains data used to animate everything in the engine.

struct Animation ;

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.

# 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)

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

Properties

NameTypeDescription
length[get, set] doubleThe total length of the animation (in seconds). Note: Length is not delimited by the last key, as this one may be before or after the end to ensure correct interpolation and looping.
loop[get, set] boolA 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.
step[get, set] doubleThe animation step value.

Methods

NameDescription
addTrack Adds a track to the Animation.
animationTrackGetKeyAnimation
animationTrackInsertKey
animationTrackSetKeyAnimation
audioTrackGetKeyEndOffset
audioTrackGetKeyStartOffset
audioTrackGetKeyStream
audioTrackInsertKey
audioTrackSetKeyEndOffset
audioTrackSetKeyStartOffset
audioTrackSetKeyStream
bezierTrackGetKeyInHandle
bezierTrackGetKeyOutHandle
bezierTrackGetKeyValue
bezierTrackInsertKey
bezierTrackInterpolate
bezierTrackSetKeyInHandle
bezierTrackSetKeyOutHandle
bezierTrackSetKeyValue
clear Clear the animation (clear all tracks and reset all).
copyTrack Adds a new track that is a copy of the given track from to_animation.
findTrack Returns the index of the specified track. If the track is not found, return -1.
getLength
getStep
getTrackCount Returns the amount of tracks in the animation.
hasLoop
methodTrackGetKeyIndices Returns all the key indices of a method track, given a position and delta time.
methodTrackGetName Returns the method name of a method track.
methodTrackGetParams Returns the arguments values to be called on a method track for a given key in a given track.
removeTrack Removes a track by specifying the track index.
setLength
setLoop
setStep
trackFindKey Finds the key index by time in a given track. Optionally, only find it if the exact time is given.
trackGetInterpolationLoopWrap Returns true if the track at idx wraps the interpolation loop. New tracks wrap the interpolation loop by default.
trackGetInterpolationType Returns the interpolation type of a given track.
trackGetKeyCount Returns the amount of keys in a given track.
trackGetKeyTime Returns the time at which the key is located.
trackGetKeyTransition Returns the transition curve (easing) for a specific key (see the built-in math function @GDScript.ease).
trackGetKeyValue Returns the value of a given key in a given track.
trackGetPath Gets the path of a track. For more information on the path format, see trackSetPath.
trackGetType Gets the type of a track.
trackInsertKey Insert a generic key in a given track.
trackIsEnabled Returns true if the track at index idx is enabled.
trackIsImported Returns true if the given track is imported. Else, return false.
trackMoveDown Moves a track down.
trackMoveTo Changes the index position of track idx to the one defined in to_idx.
trackMoveUp Moves a track up.
trackRemoveKey Removes a key by index in a given track.
trackRemoveKeyAtPosition Removes a key by position (seconds) in a given track.
trackSetEnabled Enables/disables the given track. Tracks are enabled by default.
trackSetImported Sets the given track as imported or not.
trackSetInterpolationLoopWrap If true, the track at idx wraps the interpolation loop.
trackSetInterpolationType Sets the interpolation type of a given track.
trackSetKeyTime Sets the time of an existing key.
trackSetKeyTransition Sets the transition curve (easing) for a specific key (see the built-in math function @GDScript.ease).
trackSetKeyValue Sets the value of an existing key.
trackSetPath Sets 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 ":". For example, "character/skeleton:ankle" or "character/mesh:transform/local".
trackSwap Swaps the track idx's index position with the track with_idx.
transformTrackInsertKey Insert a transform key for a transform track.
transformTrackInterpolate Returns 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).
valueTrackGetKeyIndices Returns all the key indices of a value track, given a position and delta time.
valueTrackGetUpdateMode Returns the update mode of a value track.
valueTrackSetUpdateMode Sets the update mode (see updatemode) of a value track.

Enums

NameDescription
Constants
InterpolationType
TrackType
UpdateMode