Holds data that can be used to animate anything in the engine.
This resource holds data that can be used to animate anything 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 2.0 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, 2.0, 100)
animation.length = 2.0Animations are just data containers, and must be added to nodes such as an AnimationPlayer to be played back. Animation tracks have different types, each with its own set of dedicated methods. Check TrackType to see available types.
Note: For 3D position/rotation/scale, using the dedicated TYPE_POSITION_3D, TYPE_ROTATION_3D and TYPE_SCALE_3D track types instead of TYPE_VALUE is recommended for performance reasons.
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.
Determines the behavior of both ends of the animation timeline during animation playback. This indicates whether and how the animation should be restarted, and is also used to correctly interpolate animation cycles.
Returns the animation name at the key identified by key_idx. The track_idx must be the index of an Animation Track.
Inserts a key with value animation at the given time (in seconds). The track_idx must be the index of an Animation Track.
Sets the key identified by key_idx to value animation. The track_idx must be the index of an Animation Track.
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.
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.
Returns the audio stream of the key identified by key_idx. The track_idx must be the index of an Audio Track.
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.
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.
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.
Sets the stream of the key identified by key_idx to value stream. The track_idx must be the index of an Audio Track.
Sets whether the track will be blended with other animations. If true, the audio playback volume changes depending on the blend value.
Returns the in handle of the key identified by key_idx. The track_idx must be the index of a Bezier Track.
Returns the out handle of the key identified by key_idx. The track_idx must be the index of a Bezier Track.
Returns the value of the key identified by key_idx. The track_idx must be the index of a Bezier Track.
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.
Returns the interpolated value at the given time (in seconds). The track_idx must be the index of a Bezier Track.
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.
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.
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.
Returns the interpolated blend shape value at the given time (in seconds). The track_idx must be the index of a blend shape track.
Compress the animation and all its tracks in-place. This will make track_is_compressed() return true once called on this Animation. Compressed tracks require less memory to be played, and are designed to be used for complex 3D animations (such as cutscenes) imported from external 3D software. Compression is lossy, but the difference is usually not noticeable in real world conditions.
Note: Compressed tracks have various limitations (such as not being editable from the editor), so only use compressed animations if you actually need them.
Returns the closest marker that comes after the given time. If no such marker exists, an empty string is returned.
Returns the closest marker that comes before the given time. If no such marker exists, an empty string is returned.
Optimize the animation and all its tracks in-place. This will preserve only as many keys as are necessary to keep the animation within the specified bounds.
Returns the interpolated position value at the given time (in seconds). The track_idx must be the index of a 3D position track.
Returns the interpolated rotation value at the given time (in seconds). The track_idx must be the index of a 3D rotation track.
Returns the interpolated scale value at the given time (in seconds). The track_idx must be the index of a 3D scale track.
Finds the key index by time in a given track. Optionally, only find it if the approx/exact time is given.
If limit is true, it does not return keys outside the animation range.
If backward is true, the direction is reversed in methods that rely on one directional processing.
For example, in case find_mode is FIND_MODE_NEAREST, if there is no key in the current position just after seeked, the first key found is retrieved by searching before the position, but if backward is true, the first key found is retrieved after the position.
Returns true if the track at track_idx wraps the interpolation loop. New tracks wrap the interpolation loop by default.
Returns the transition curve (easing) for a specific key (see the built-in math function ease()).
Gets the path of a track. For more information on the path format, see track_set_path().
Returns true if the track is compressed, false otherwise. See also compress().
Sets the interpolation type of a given track.
Sets the transition curve (easing) for a specific key (see the built-in math function ease()).
Sets the path of a track. Paths must be valid scene-tree paths to a node and must be specified starting from the AnimationMixer.root_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".
Returns the interpolated value at the given time (in seconds). The track_idx must be the index of a value track.
A backward mainly affects the direction of key retrieval of the track with UPDATE_DISCRETE converted by AnimationMixer.ANIMATION_CALLBACK_MODE_DISCRETE_FORCE_CONTINUOUS to match the result with track_find_key().
TYPE_VALUE = 0Value tracks set values in node properties, but only those which can be interpolated. For 3D position/rotation/scale, using the dedicated TYPE_POSITION_3D, TYPE_ROTATION_3D and TYPE_SCALE_3D track types instead of TYPE_VALUE is recommended for performance reasons.
TYPE_POSITION_3D = 13D position track (values are stored in Vector3s).
TYPE_ROTATION_3D = 23D rotation track (values are stored in Quaternions).
TYPE_SCALE_3D = 33D scale track (values are stored in Vector3s).
TYPE_BLEND_SHAPE = 4Blend shape track.
TYPE_METHOD = 5Method tracks call functions with given arguments per key.
TYPE_BEZIER = 6Bezier tracks are used to interpolate a value using custom curves. They can also be used to animate sub-properties of vectors and colors (e.g. alpha value of a Color).
TYPE_AUDIO = 7Audio tracks are used to play an audio stream with either type of AudioStreamPlayer. The stream can be trimmed and previewed in the animation.
TYPE_ANIMATION = 8Animation tracks play animations in other AnimationPlayer nodes.
INTERPOLATION_NEAREST = 0No interpolation (nearest value).
INTERPOLATION_LINEAR = 1Linear interpolation.
INTERPOLATION_CUBIC = 2Cubic interpolation. This looks smoother than linear interpolation, but is more expensive to interpolate. Stick to INTERPOLATION_LINEAR for complex 3D animations imported from external software, even if it requires using a higher animation framerate in return.
INTERPOLATION_LINEAR_ANGLE = 3Linear interpolation with shortest path rotation.
Note: The result value is always normalized and may not match the key value.
INTERPOLATION_CUBIC_ANGLE = 4Cubic interpolation with shortest path rotation.
Note: The result value is always normalized and may not match the key value.
UPDATE_CONTINUOUS = 0Update between keyframes and hold the value.
UPDATE_DISCRETE = 1Update at the keyframes.
UPDATE_CAPTURE = 2Same as UPDATE_CONTINUOUS but works as a flag to capture the value of the current object and perform interpolation in some methods. See also AnimationMixer.capture(), AnimationPlayer.playback_auto_capture, and AnimationPlayer.play_with_capture().
LOOP_NONE = 0At both ends of the animation, the animation will stop playing.
LOOP_LINEAR = 1At both ends of the animation, the animation will be repeated without changing the playback direction.
LOOP_PINGPONG = 2Repeats playback and reverse playback at both ends of the animation.
LOOPED_FLAG_NONE = 0This flag indicates that the animation proceeds without any looping.
LOOPED_FLAG_END = 1This flag indicates that the animation has reached the end of the animation and just after loop processed.
LOOPED_FLAG_START = 2This flag indicates that the animation has reached the start of the animation and just after loop processed.