Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Animation

Inherits: Resource < RefCounted < Object

Holds data that can be used to animate anything in the engine.

Description

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.0

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 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.

Tutorials

Properties

float

length

1.0

LoopMode

loop_mode

0

float

step

0.1

Methods

int

add_track(type: TrackType, at_position: int = -1)

StringName

animation_track_get_key_animation(track_idx: int, key_idx: int) const

int

animation_track_insert_key(track_idx: int, time: float, animation: StringName)

void

animation_track_set_key_animation(track_idx: int, key_idx: int, animation: StringName)

float

audio_track_get_key_end_offset(track_idx: int, key_idx: int) const

float

audio_track_get_key_start_offset(track_idx: int, key_idx: int) const

Resource

audio_track_get_key_stream(track_idx: int, key_idx: int) const

int

audio_track_insert_key(track_idx: int, time: float, stream: Resource, start_offset: float = 0, end_offset: float = 0)

bool

audio_track_is_use_blend(track_idx: int) const

void

audio_track_set_key_end_offset(track_idx: int, key_idx: int, offset: float)

void

audio_track_set_key_start_offset(track_idx: int, key_idx: int, offset: float)

void

audio_track_set_key_stream(track_idx: int, key_idx: int, stream: Resource)

void

audio_track_set_use_blend(track_idx: int, enable: bool)

Vector2

bezier_track_get_ke