Animation

Contains data used to animate everything in the engine.

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.

More...
@GodotBaseClass
struct Animation {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Constants
enum Constants
InterpolationType
enum InterpolationType
TrackType
enum TrackType
UpdateMode
enum UpdateMode

Functions

addTrack
long addTrack(long type, long at_position)

Adds a track to the Animation.

animationTrackGetKeyAnimation
String animationTrackGetKeyAnimation(long track_idx, long key_idx)

Returns the animation name at the key identified by key_idx. The track_idx must be the index of an Animation Track.

animationTrackInsertKey
long animationTrackInsertKey(long track_idx, double time, String animation)

Inserts a key with value animation at the given time (in seconds). The track_idx must be the index of an Animation Track.

animationTrackSetKeyAnimation
void animationTrackSetKeyAnimation(long track_idx, long key_idx, String animation)

Sets the key identified by key_idx to value animation. The track_idx must be the index of an Animation Track.

audioTrackGetKeyEndOffset
double audioTrackGetKeyEndOffset(long track_idx, long key_idx)

Returns the end offset of the key identified by key_idx. The track_idx must be the index of an Audio Track. End offset is the number of seconds cut off at the ending of the audio stream.

audioTrackGetKeyStartOffset
double audioTrackGetKeyStartOffset(long track_idx, long key_idx)

Returns the start offset of the key identified by key_idx. The track_idx must be the index of an Audio Track. Start offset is the number of seconds cut off at the beginning of the audio stream.

audioTrackGetKeyStream
Ref!Resource audioTrackGetKeyStream(long track_idx, long key_idx)

Returns the audio stream of the key identified by key_idx. The track_idx must be the index of an Audio Track.

audioTrackInsertKey
long audioTrackInsertKey(long track_idx, double time, Resource stream, double start_offset, double end_offset)

Inserts an Audio Track key at the given time in seconds. The track_idx must be the index of an Audio Track. stream is the AudioStream resource to play. start_offset is the number of seconds cut off at the beginning of the audio stream, while end_offset is at the ending.

audioTrackSetKeyEndOffset
void audioTrackSetKeyEndOffset(long track_idx, long key_idx, double offset)

Sets the end offset of the key identified by key_idx to value offset. The track_idx must be the index of an Audio Track.

audioTrackSetKeyStartOffset
void audioTrackSetKeyStartOffset(long track_idx, long key_idx, double offset)

Sets the start offset of the key identified by key_idx to value offset. The track_idx must be the index of an Audio Track.

audioTrackSetKeyStream
void audioTrackSetKeyStream(long track_idx, long key_idx, Resource stream)

Sets the stream of the key identified by key_idx to value stream. The track_idx must be the index of an Audio Track.

bezierTrackGetKeyInHandle
Vector2 bezierTrackGetKeyInHandle(long track_idx, long key_idx)

Returns the in handle of the key identified by key_idx. The track_idx must be the index of a Bezier Track.

bezierTrackGetKeyOutHandle
Vector2 bezierTrackGetKeyOutHandle(long track_idx, long key_idx)

Returns the out handle of the key identified by key_idx. The track_idx must be the index of a Bezier Track.

bezierTrackGetKeyValue
double bezierTrackGetKeyValue(long track_idx, long key_idx)

Returns the value of the key identified by key_idx. The track_idx must be the index of a Bezier Track.

bezierTrackInsertKey
long bezierTrackInsertKey(long track_idx, double time, double value, Vector2 in_handle, Vector2 out_handle)

Inserts a Bezier Track key at the given time in seconds. The track_idx must be the index of a Bezier Track. in_handle is the left-side weight of the added Bezier curve point, out_handle is the right-side one, while value is the actual value at this point.

bezierTrackInterpolate
double bezierTrackInterpolate(long track_idx, double time)

Returns the interpolated value at the given time (in seconds). The track_idx must be the index of a Bezier Track.

bezierTrackSetKeyInHandle
void bezierTrackSetKeyInHandle(long track_idx, long key_idx, Vector2 in_handle)

Sets the in handle of the key identified by key_idx to value in_handle. The track_idx must be the index of a Bezier Track.

bezierTrackSetKeyOutHandle
void bezierTrackSetKeyOutHandle(long track_idx, long key_idx, Vector2 out_handle)

Sets the out handle of the key identified by key_idx to value out_handle. The track_idx must be the index of a Bezier Track.

bezierTrackSetKeyValue
void bezierTrackSetKeyValue(long track_idx, long key_idx, double value)

Sets the value of the key identified by key_idx to the given value. The track_idx must be the index of a Bezier Track.

clear
void clear()

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

copyTrack
void copyTrack(long track_idx, Animation to_animation)

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

findTrack
long findTrack(NodePathArg0 path)

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

getLength
double getLength()
getStep
double getStep()
getTrackCount
long getTrackCount()

Returns the amount of tracks in the animation.

hasLoop
bool hasLoop()
methodTrackGetKeyIndices
PoolIntArray methodTrackGetKeyIndices(long track_idx, double time_sec, double delta)

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

methodTrackGetName
String methodTrackGetName(long track_idx, long key_idx)

Returns the method name of a method track.

methodTrackGetParams
Array methodTrackGetParams(long track_idx, long key_idx)

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

opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(Animation other)
opEquals
bool opEquals(typeof(null) n)
removeTrack
void removeTrack(long track_idx)

Removes a track by specifying the track index.

setLength
void setLength(double time_sec)
setLoop
void setLoop(bool enabled)
setStep
void setStep(double size_sec)
toHash
size_t toHash()
trackFindKey
long trackFindKey(long track_idx, double time, bool exact)

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

trackGetInterpolationLoopWrap
bool trackGetInterpolationLoopWrap(long track_idx)

Returns true if the track at idx wraps the interpolation loop. New tracks wrap the interpolation loop by default.

trackGetInterpolationType
Animation.InterpolationType trackGetInterpolationType(long track_idx)

Returns the interpolation type of a given track.

trackGetKeyCount
long trackGetKeyCount(long track_idx)

Returns the amount of keys in a given track.

trackGetKeyTime
double trackGetKeyTime(long track_idx, long key_idx)

Returns the time at which the key is located.

trackGetKeyTransition
double trackGetKeyTransition(long track_idx, long key_idx)

Returns the transition curve (easing) for a specific key (see the built-in math function @GDScript.ease).

trackGetKeyValue
Variant trackGetKeyValue(long track_idx, long key_idx)

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

trackGetPath
NodePath trackGetPath(long track_idx)

Gets the path of a track. For more information on the path format, see trackSetPath.

trackGetType
Animation.TrackType trackGetType(long track_idx)

Gets the type of a track.

trackInsertKey
void trackInsertKey(long track_idx, double time, VariantArg2 key, double transition)

Insert a generic key in a given track.

trackIsEnabled
bool trackIsEnabled(long track_idx)

Returns true if the track at index idx is enabled.

trackIsImported
bool trackIsImported(long track_idx)

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

trackMoveDown
void trackMoveDown(long track_idx)

Moves a track down.

trackMoveTo
void trackMoveTo(long track_idx, long to_idx)

Changes the index position of track idx to the one defined in to_idx.

trackMoveUp
void trackMoveUp(long track_idx)

Moves a track up.

trackRemoveKey
void trackRemoveKey(long track_idx, long key_idx)

Removes a key by index in a given track.

trackRemoveKeyAtPosition
void trackRemoveKeyAtPosition(long track_idx, double position)

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

trackSetEnabled
void trackSetEnabled(long track_idx, bool enabled)

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

trackSetImported
void trackSetImported(long track_idx, bool imported)

Sets the given track as imported or not.

trackSetInterpolationLoopWrap
void trackSetInterpolationLoopWrap(long track_idx, bool interpolation)

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

trackSetInterpolationType
void trackSetInterpolationType(long track_idx, long interpolation)

Sets the interpolation type of a given track.

trackSetKeyTime
void trackSetKeyTime(long track_idx, long key_idx, double time)

Sets the time of an existing key.

trackSetKeyTransition
void trackSetKeyTransition(long track_idx, long key_idx, double transition)

Sets the transition curve (easing) for a specific key (see the built-in math function @GDScript.ease).

trackSetKeyValue
void trackSetKeyValue(long track_idx, long key, VariantArg2 value)

Sets the value of an existing key.

trackSetPath
void trackSetPath(long track_idx, NodePathArg1 path)

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
void trackSwap(long track_idx, long with_idx)

Swaps the track idx's index position with the track with_idx.

transformTrackInsertKey
long transformTrackInsertKey(long track_idx, double time, Vector3 location, Quat rotation, Vector3 scale)

Insert a transform key for a transform track.

transformTrackInterpolate
Array transformTrackInterpolate(long track_idx, double time_sec)

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
PoolIntArray valueTrackGetKeyIndices(long track_idx, double time_sec, double delta)

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

valueTrackGetUpdateMode
Animation.UpdateMode valueTrackGetUpdateMode(long track_idx)

Returns the update mode of a value track.

valueTrackInterpolate
Variant valueTrackInterpolate(long track_idx, double time_sec)

Returns the interpolated value at the given time (in seconds). The track_idx must be the index of a value track.

valueTrackSetUpdateMode
void valueTrackSetUpdateMode(long track_idx, long mode)

Sets the update mode (see updatemode) of a value track.

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

length
double length [@property getter]
double length [@property setter]

The 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
bool loop [@property getter]
bool loop [@property setter]

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

step
double step [@property getter]
double step [@property setter]

The animation step value.

Static functions

_new
Animation _new()

Construct a new instance of Animation. Note: use memnew!Animation instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Detailed Description

# This creates an animation that makes the node "Enemy" move to the right by # 100 pixels in 0.5 seconds. 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. Animation tracks have different types, each with its own set of dedicated methods. Check tracktype to see available types.

Meta