AnimationPlayer

Inherits: Node < Object

Category: Core

Brief Description

Container and player of Animation resources.

Member Functions

int add_animation ( String name, Animation animation )
void advance ( float delta )
String animation_get_next ( String anim_from ) const
void animation_set_next ( String anim_from, String anim_to )
void clear_caches ( )
void clear_queue ( )
String find_animation ( Animation animation ) const
Animation get_animation ( String name ) const
StringArray get_animation_list ( ) const
int get_animation_process_mode ( ) const
String get_autoplay ( ) const
float get_blend_time ( String anim_from, String anim_to ) const
String get_current_animation ( ) const
float get_current_animation_length ( ) const
float get_current_animation_pos ( ) const
float get_default_blend_time ( ) const
float get_pos ( ) const
NodePath get_root ( ) const
float get_speed ( ) const
bool has_animation ( String name ) const
bool is_active ( ) const
bool is_playing ( ) const
void play ( String name=””, float custom_blend=-1, float custom_speed=1, bool from_end=false )
void play_backwards ( String name=””, float custom_blend=-1 )
void queue ( String name )
void remove_animation ( String name )
void rename_animation ( String name, String newname )
void seek ( float pos_sec, bool update=false )
void set_active ( bool active )
void set_animation_process_mode ( int mode )
void set_autoplay ( String name )
void set_blend_time ( String anim_from, String anim_to, float sec )
void set_current_animation ( String anim )
void set_default_blend_time ( float sec )
void set_root ( NodePath path )
void set_speed ( float speed )
void stop ( bool reset=true )
void stop_all ( )

Signals

  • animation_changed ( String old_name, String new_name )
  • finished ( )

Numeric Constants

  • ANIMATION_PROCESS_FIXED = 0 — Process animation on fixed process. This is specially useful when animating kinematic bodies.
  • ANIMATION_PROCESS_IDLE = 1 — Process animation on idle process.

Description

An animation player is used for general purpose playback of Animation resources. It contains a dictionary of animations (referenced by name) and custom blend times between their transitions. Additionally, animations can be played and blended in different channels.

Member Function Description

Add an animation resource to the player, which will be later referenced by the “name” argument.

  • void advance ( float delta )

Used to skip ahead or skip back in an animation. Delta is the time in seconds to skip.

  • void animation_set_next ( String anim_from, String anim_to )
  • void clear_caches ( )

The animation player creates caches for faster access to the nodes it will animate. However, if a specific node is removed, it may not notice it, so clear_caches will force the player to search for the nodes again.

  • void clear_queue ( )

If animations are queued to play, clear them.

Find an animation name by resource.

Get an Animation resource by requesting a name.

Get the list of names of the animations stored in the player.

  • int get_animation_process_mode ( ) const

Return the mode in which the animation player processes. See set_animation_process_mode.

  • String get_autoplay ( ) const

Return the name of the animation that will be automatically played when the scene is loaded.

Get the blend time between two animations, referenced by their names.

  • String get_current_animation ( ) const

Return the name of the animation being played.

  • float get_current_animation_length ( ) const

Get the length (in seconds) of the currently being played animation.

  • float get_current_animation_pos ( ) const

Get the position (in seconds) of the currently being played animation.

  • float get_default_blend_time ( ) const

Return the default blend time between animations.

  • float get_pos ( ) const

Return the playback position (in seconds) in an animation channel (or channel 0 if none is provided).

Return path to root node (see set_root).

  • float get_speed ( ) const

Get the speed scaling ratio in a given animation channel (or channel 0 if none is provided). Default ratio is 1 (no scaling).

Request whether an Animation name exist within the player.

  • bool is_active ( ) const

Return true if the player is active.

  • bool is_playing ( ) const

Return whether an animation is playing.

  • void play ( String name=””, float custom_blend=-1, float custom_speed=1, bool from_end=false )

Play a given animation by the animation name. Custom speed and blend times can be set. If custom speed is negative (-1), ‘from_end’ being true can play the animation backwards.

  • void play_backwards ( String name=””, float custom_blend=-1 )

Play a given animation by the animation name in reverse.

Queue an animation for playback once the current one is done.

  • void remove_animation ( String name )

Remove an animation from the player (by supplying the same name used to add it).

Rename an existing animation.

  • void seek ( float pos_sec, bool update=false )

Seek the animation to a given position in time (in seconds). If ‘update’ is true, the animation will be updated too, otherwise it will be updated at process time.

  • void set_active ( bool active )

Set the player as active (playing). If false, it

will do nothing.

  • void set_animation_process_mode ( int mode )

Set the mode in which the animation player processes. By default, it processes on idle time (framerate dependent), but using fixed time works well for animating static collision bodies in 2D and 3D. See enum ANIMATION_PROCESS_*.

  • void set_autoplay ( String name )

Set the name of the animation that will be automatically played when the scene is loaded.

Specify a blend time (in seconds) between two animations, referenced by their names.

  • void set_current_animation ( String anim )

Set the current animation (even if no playback occurs). Using set_current_animation() and set_active() are similar to calling play().

  • void set_default_blend_time ( float sec )

Set the default blend time between animations.

AnimationPlayer resolves animation track paths from this node (which is relative to itself), by default root is ”..”, but it can be changed.

  • void set_speed ( float speed )

Set a speed scaling ratio in a given animation channel (or channel 0 if none is provided). Default ratio is 1 (no scaling).

  • void stop ( bool reset=true )

Stop the currently playing animation.

  • void stop_all ( )

Stop playback of animations (deprecated).