Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
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
// 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;
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¶
|
||
|
||
|
Methods¶
animation_track_get_key_animation ( int track_idx, int key_idx ) const |
|
animation_track_insert_key ( int track_idx, float time, StringName animation ) |
|
void |
animation_track_set_key_animation ( int track_idx, int key_idx, StringName animation ) |
audio_track_get_key_end_offset ( int track_idx, int key_idx ) const |
|
audio_track_get_key_start_offset ( int track_idx, int key_idx ) const |
|
audio_track_get_key_stream ( int track_idx, int key_idx ) const |
|
audio_track_insert_key ( int track_idx, float time, Resource stream, float start_offset=0, float end_offset=0 ) |
|
audio_track_is_use_blend ( int track_idx ) const |
|
void |
audio_track_set_key_end_offset ( int track_idx, int key_idx, float offset ) |
void |
audio_track_set_key_start_offset ( int track_idx, int key_idx, float offset ) |
void |
audio_track_set_key_stream ( int track_idx, int key_idx, Resource stream ) |
void |
audio_track_set_use_blend ( int track_idx, bool enable ) |
bezier_track_get_key_in_handle ( int track_idx, int key_idx ) const |
|
bezier_track_get_key_out_handle ( int track_idx, int key_idx ) const |
|
bezier_track_get_key_value ( int track_idx, int key_idx ) const |
|
bezier_track_insert_key ( int track_idx, float time, float value, Vector2 in_handle=Vector2(0, 0), Vector2 out_handle=Vector2(0, 0) ) |
|
bezier_track_interpolate ( int track_idx, float time ) const |
|
void |
bezier_track_set_key_in_handle ( int track_idx, int key_idx, Vector2 in_handle, float balanced_value_time_ratio=1.0 ) |
void |
bezier_track_set_key_out_handle ( int track_idx, int key_idx, Vector2 out_handle, float balanced_value_time_ratio=1.0 ) |
void |
bezier_track_set_key_value ( int track_idx, int key_idx, float value ) |
blend_shape_track_insert_key ( int track_idx, float time, float amount ) |
|
blend_shape_track_interpolate ( int track_idx, float time_sec ) const |
|
void |
clear ( ) |
void |
compress ( int page_size=8192, int fps=120, float split_tolerance=4.0 ) |
void |
copy_track ( int track_idx, Animation to_animation ) |
find_track ( NodePath path, TrackType type ) const |
|
get_track_count ( ) const |
|
method_track_get_name ( int track_idx, int key_idx ) const |
|
method_track_get_params ( int track_idx, int key_idx ) const |
|
position_track_insert_key ( int track_idx, float time, Vector3 position ) |
|