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. [codeblocks] [gdscript] # 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.0 [/gdscript] [csharp] // This creates an animation that makes the node "Enemy" move to the right by // 100 pixels in 2.0 seconds. var animation = new Animation(); int trackIndex = animation.AddTrack(Animation.TrackType.Value); animation.TrackSetPath(trackIndex, "Enemy:position:x"); animation.TrackInsertKey(trackIndex, 0.0f, 0); animation.TrackInsertKey(trackIndex, 2.0f, 100); animation.Length = 2.0f; [/csharp] [/codeblocks] Animations 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 [enum TrackType] to see available types. [b]Note:[/b] For 3D position/rotation/scale, using the dedicated [constant TYPE_POSITION_3D], [constant TYPE_ROTATION_3D] and [constant TYPE_SCALE_3D] track types instead of [constant TYPE_VALUE] is recommended for performance reasons. $DOCS_URL/tutorials/animation/index.html Adds a track to the Animation. Returns the animation name at the key identified by [param key_idx]. The [param track_idx] must be the index of an Animation Track. Inserts a key with value [param animation] at the given [param time] (in seconds). The [param track_idx] must be the index of an Animation Track. Sets the key identified by [param key_idx] to value [param animation]. The [param track_idx] must be the index of an Animation Track. Returns the end offset of the key identified by [param key_idx]. The [param 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 [param key_idx]. The [param 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 [param key_idx]. The [param track_idx] must be the index of an Audio Track. Inserts an Audio Track key at the given [param time] in seconds. The [param track_idx] must be the index of an Audio Track. [param stream] is the [AudioStream] resource to play. [param start_offset] is the number of seconds cut off at the beginning of the audio stream, while [param end_offset] is at the ending. Returns [code]true[/code] if the track at [param track_idx] will be blended with other animations. Sets the end offset of the key identified by [param key_idx] to value [param offset]. The [param track_idx] must be the index of an Audio Track. Sets the start offset of the key identified by [param key_idx] to value [param offset]. The [param track_idx] must be the index of an Audio Track. Sets the stream of the key identified by [param key_idx] to value [param stream]. The [param track_idx] must be the index of an Audio Track. Sets whether the track will be blended with other animations. If [code]true[/code], the audio playback volume changes depending on the blend value. Returns the in handle of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track. Returns the out handle of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track. Returns the value of the key identified by [param key_idx]. The [param track_idx] must be the index of a Bezier Track. Inserts a Bezier Track key at the given [param time] in seconds. The [param track_idx] must be the index of a Bezier Track. [param in_handle] is the left-side weight of the added Bezier curve point, [param out_handle] is the right-side one, while [param value] is the actual value at this point. Returns the interpolated value at the given [param time] (in seconds). The [param track_idx] must be the index of a Bezier Track. Sets the in handle of the key identified by [param key_idx] to value [param in_handle]. The [param track_idx] must be the index of a Bezier Track. Sets the out handle of the key identified by [param key_idx] to value [param out_handle]. The [param track_idx] must be the index of a Bezier Track. Sets the value of the key identified by [param key_idx] to the given value. The [param track_idx] must be the index of a Bezier Track. Inserts a key in a given blend shape track. Returns the key index. Returns the interpolated blend shape value at the given time (in seconds). The [param track_idx] must be the index of a blend shape track. Clear the animation (clear all tracks and reset all). Compress the animation and all its tracks in-place. This will make [method track_is_compressed] return [code]true[/code] 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. [b]Note:[/b] Compressed tracks have various limitations (such as not being editable from the editor), so only use compressed animations if you actually need them. Adds a new track to [param to_animation] that is a copy of the given track from this animation. Returns the index of the specified track. If the track is not found, return -1. Returns the amount of tracks in the animation. Returns the method name of a method track. Returns the arguments values to be called on a method track for a given key in a given track. Inserts a key in a given 3D position track. Returns the key index. Returns the interpolated position value at the given time (in seconds). The [param track_idx] must be the index of a 3D position track. Removes a track by specifying the track index. Inserts a key in a given 3D rotation track. Returns the key index. Returns the interpolated rotation value at the given time (in seconds). The [param track_idx] must be the index of a 3D rotation track. Inserts a key in a given 3D scale track. Returns the key index. Returns the interpolated scale value at the given time (in seconds). The [param 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 [param limit] is [code]true[/code], it does not return keys outside the animation range. Returns [code]true[/code] if the track at [param track_idx] wraps the interpolation loop. New tracks wrap the interpolation loop by default. Returns the interpolation type of a given track. Returns the number of keys in a given track. Returns the time at which the key is located. Returns the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]). Returns the value of a given key in a given track. Gets the path of a track. For more information on the path format, see [method track_set_path]. Gets the type of a track. Inserts a generic key in a given track. Returns the key index. Returns [code]true[/code] if the track is compressed, [code]false[/code] otherwise. See also [method compress]. Returns [code]true[/code] if the track at index [param track_idx] is enabled. Returns [code]true[/code] if the given track is imported. Else, return [code]false[/code]. Moves a track down. Changes the index position of track [param track_idx] to the one defined in [param to_idx]. Moves a track up. Removes a key by index in a given track. Removes a key at [param time] in a given track. Enables/disables the given track. Tracks are enabled by default. Sets the given track as imported or not. If [code]true[/code], the track at [param track_idx] wraps the interpolation loop. Sets the interpolation type of a given track. Sets the time of an existing key. Sets the transition curve (easing) for a specific key (see the built-in math function [method @GlobalScope.ease]). Sets the value of an existing key. 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 [code]":"[/code]. For example, [code]"character/skeleton:ankle"[/code] or [code]"character/mesh:transform/local"[/code]. Swaps the track [param track_idx]'s index position with the track [param with_idx]. Returns the update mode of a value track. Returns the interpolated value at the given time (in seconds). The [param track_idx] must be the index of a value track. Sets the update mode (see [enum UpdateMode]) of a value track. The total length of the animation (in seconds). [b]Note:[/b] 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 is used for correct interpolation of animation cycles, and for hinting the player that it must restart the animation. The animation step value. Value tracks set values in node properties, but only those which can be interpolated. For 3D position/rotation/scale, using the dedicated [constant TYPE_POSITION_3D], [constant TYPE_ROTATION_3D] and [constant TYPE_SCALE_3D] track types instead of [constant TYPE_VALUE] is recommended for performance reasons. 3D position track (values are stored in [Vector3]s). 3D rotation track (values are stored in [Quaternion]s). 3D scale track (values are stored in [Vector3]s). Blend shape track. Method tracks call functions with given arguments per key. Bezier 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]). Audio tracks are used to play an audio stream with either type of [AudioStreamPlayer]. The stream can be trimmed and previewed in the animation. Animation tracks play animations in other [AnimationPlayer] nodes. No interpolation (nearest value). Linear interpolation. Cubic interpolation. This looks smoother than linear interpolation, but is more expensive to interpolate. Stick to [constant INTERPOLATION_LINEAR] for complex 3D animations imported from external software, even if it requires using a higher animation framerate in return. Linear interpolation with shortest path rotation. [b]Note:[/b] The result value is always normalized and may not match the key value. Cubic interpolation with shortest path rotation. [b]Note:[/b] The result value is always normalized and may not match the key value. Update between keyframes and hold the value. Update at the keyframes. Same as [constant UPDATE_CONTINUOUS] but works as a flag to capture the value of the current object and perform interpolation in some methods. See also [method AnimationMixer.capture] and [method AnimationPlayer.play_with_capture]. At both ends of the animation, the animation will stop playing. At both ends of the animation, the animation will be repeated without changing the playback direction. Repeats playback and reverse playback at both ends of the animation. This flag indicates that the animation proceeds without any looping. This flag indicates that the animation has reached the end of the animation and just after loop processed. This flag indicates that the animation has reached the start of the animation and just after loop processed. Finds the nearest time key. Finds only the key with approximating the time. Finds only the key with matching the time.