AnimationPlayer
Hereda: AnimationMixer < Node < Object
Un nodo utilizado para la reproducción de animación.
Descripción
An animation player is used for general-purpose playback of animations. It contains a dictionary of AnimationLibrary resources and custom blend times between animation transitions.
Some methods and properties use a single key to reference an animation directly. These keys are formatted as the key for the library, followed by a forward slash, then the key for the animation within the library, for example "movement/run". If the library's key is an empty string (known as the default library), the forward slash is omitted, being the same key used by the library.
AnimationPlayer is better-suited than Tween for more complex animations, for example ones with non-trivial timings. It can also be used over Tween if the animation track editor is more convenient than doing it in code.
Updating the target properties of animations occurs at the process frame.
Tutoriales
Propiedades
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Métodos
animation_get_next(animation_from: StringName) const |
|
void |
animation_set_next(animation_from: StringName, animation_to: StringName) |
void |
|
get_blend_time(animation_from: StringName, animation_to: StringName) const |
|
get_method_call_mode() const |
|
get_playing_speed() const |
|
get_process_callback() const |
|
get_root() const |
|
get_section_end_time() const |
|
get_section_start_time() const |
|
has_section() const |
|
is_animation_active() const |
|
is_playing() const |
|
void |
pause() |
void |
play(name: StringName = &"", custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false) |
void |
play_backwards(name: StringName = &"", custom_blend: float = -1) |
void |
play_section(name: StringName = &"", start_time: float = -1, end_time: float = -1, custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false) |
void |
play_section_backwards(name: StringName = &"", start_time: float = -1, end_time: float = -1, custom_blend: float = -1) |
void |
play_section_with_markers(name: StringName = &"", start_marker: StringName = &"", end_marker: StringName = &"", custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false) |
void |
play_section_with_markers_backwards(name: StringName = &"", start_marker: StringName = &"", end_marker: StringName = &"", custom_blend: float = -1) |
void |
play_with_capture(name: StringName = &"", duration: float = -1.0, custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false, trans_type: TransitionType = 0, ease_type: EaseType = 0) |
void |
queue(name: StringName) |
void |
|
void |
seek(seconds: float, update: bool = false, update_only: bool = false) |
void |
set_blend_time(animation_from: StringName, animation_to: StringName, sec: float) |
void |
|
void |
|
void |
|
void |
set_section(start_time: float = -1, end_time: float = -1) |
void |
set_section_with_markers(start_marker: StringName = &"", end_marker: StringName = &"") |
void |
Señales
animation_changed(old_name: StringName, new_name: StringName) 🔗
Emitida cuando una animación en cola se reproduce después de que la animación anterior haya terminado. Véase también queue().
Nota: La señal no se emite cuando la animación se cambia a través de play() o por un AnimationTree.
current_animation_changed(name: StringName) 🔗
Emitida cuando current_animation cambia.
Enumeraciones
enum AnimationProcessCallback: 🔗
AnimationProcessCallback ANIMATION_PROCESS_PHYSICS = 0
Obsoleto: See AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_PHYSICS.
AnimationProcessCallback ANIMATION_PROCESS_IDLE = 1
Obsoleto: See AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_IDLE.
AnimationProcessCallback ANIMATION_PROCESS_MANUAL = 2
Obsoleto: See AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_MANUAL.
enum AnimationMethodCallMode: 🔗
AnimationMethodCallMode ANIMATION_METHOD_CALL_DEFERRED = 0
Obsoleto: See AnimationMixer.ANIMATION_CALLBACK_MODE_METHOD_DEFERRED.
AnimationMethodCallMode ANIMATION_METHOD_CALL_IMMEDIATE = 1
Obsoleto: See AnimationMixer.ANIMATION_CALLBACK_MODE_METHOD_IMMEDIATE.
Descripciones de Propiedades
StringName assigned_animation 🔗
void set_assigned_animation(value: StringName)
StringName get_assigned_animation()
Si se está reproduciendo, la clave de la animación actual; en caso contrario, la de la última animación reproducida. Cuando se establece, esto cambia la animación, pero no la reproducirá a menos que ya se esté reproduciendo. Véase también current_animation.
StringName autoplay = &"" 🔗
void set_autoplay(value: StringName)
StringName get_autoplay()
La clave de la animación que se reproducirá cuando se cargue la escena.
StringName current_animation = &"" 🔗
void set_current_animation(value: StringName)
StringName get_current_animation()
La clave de la animación que se está reproduciendo actualmente. Si no se está reproduciendo ninguna animación, el valor de la propiedad es una string vacía. Cambiar este valor no reinicia la animación. Véase play() para más información sobre la reproducción de animaciones.
Nota: Aunque esta propiedad aparece en el Inspector, no está pensada para ser editada y no se guarda en la escena. Esta propiedad se usa principalmente para obtener la animación que se está reproduciendo actualmente, e internamente para las pistas de reproducción de animación. Para más información, véase Animation.
float current_animation_length 🔗
float get_current_animation_length()
La duración (en segundos) de la animación que se está reproduciendo actualmente.
float current_animation_position 🔗
float get_current_animation_position()
La posición (en segundos) de la animación que se está reproduciendo.
bool movie_quit_on_finish = false 🔗
If true and the engine is running in Movie Maker mode (see MovieWriter), exits the engine with SceneTree.quit() as soon as an animation is done playing in this AnimationPlayer. A message is printed when the engine quits for this reason.
Note: This obeys the same logic as the AnimationMixer.animation_finished signal, so it will not quit the engine if the animation is set to be looping.
bool playback_auto_capture = true 🔗
Si es true, realiza AnimationMixer.capture() antes de la reproducción automáticamente. Esto significa que se ejecuta simplemente play_with_capture() con argumentos por defecto en lugar de play().
Nota: La interpolación de captura solo se realiza si la animación contiene una pista de captura. Véase también Animation.UPDATE_CAPTURE.
float playback_auto_capture_duration = -1.0 🔗
Véase también play_with_capture() y AnimationMixer.capture().
Si playback_auto_capture_duration es un value negativo, la duración se establece al intervalo entre la posición actual y la primera key.
EaseType playback_auto_capture_ease_type = 0 🔗
El tipo de facilidad de la interpolación de captura. Véase también EaseType.
TransitionType playback_auto_capture_transition_type = 0 🔗
void set_auto_capture_transition_type(value: TransitionType)
TransitionType get_auto_capture_transition_type()
El tipo de transición de la interpolación de captura. Véase TransitionType.
float playback_default_blend_time = 0.0 🔗
El tiempo por defecto para mezclar las animaciones. Va de 0 a 4096 con una precisión de 0,01.
La relación de escala de velocidad. Por ejemplo, si este valor es 1, entonces la animación se reproduce a velocidad normal. Si es 0.5, entonces se reproduce a media velocidad. Si es 2, entonces se reproduce al doble de velocidad.
Si se establece en un valor negativo, la animación se reproduce en reversa. Si se establece en 0, la animación no avanzará.
Descripciones de Métodos
StringName animation_get_next(animation_from: StringName) const 🔗
Devuelve la clave de la animación que está en cola para reproducirse después de la animación animation_from.
void animation_set_next(animation_from: StringName, animation_to: StringName) 🔗
Dispara la animación animation_to cuando la animación animation_from se completa.
void clear_queue() 🔗
Limpia todas las colas, animaciones no reproducidas.
float get_blend_time(animation_from: StringName, animation_to: StringName) const 🔗
Devuelve el tiempo de fusión (en segundos) entre dos animaciones, referenciado por sus claves.
AnimationMethodCallMode get_method_call_mode() const 🔗
Obsoleto: Use AnimationMixer.callback_mode_method instead.
Devuelve el modo de llamada utilizado para las pistas de "Call Method".
float get_playing_speed() const 🔗
Devuelve la velocidad de reproducción real de la animación actual o 0 si no se está reproduciendo. Esta velocidad es la propiedad speed_scale multiplicada por el argumento custom_speed especificado al llamar al método play().
Devuelve un valor negativo si la animación actual se está reproduciendo hacia atrás.
AnimationProcessCallback get_process_callback() const 🔗
Obsoleto: Use AnimationMixer.callback_mode_process instead.
Devuelve la notificación del proceso en el que se actualizarán las animaciones.
Array[StringName] get_queue() 🔗
Devuelve una lista de las claves de animación que están actualmente en cola para reproducirse.
Obsoleto: Use AnimationMixer.root_node instead.
Devuelve el nodo desde el cual viajarán las referencias de la ruta de nodos.
float get_section_end_time() const 🔗
Devuelve el tiempo de finalización de la sección que se está reproduciendo actualmente.
float get_section_start_time() const 🔗
Devuelve el tiempo de inicio de la sección que se está reproduciendo actualmente.
Devuelve true si una animación se está reproduciendo actualmente con una sección.
bool is_animation_active() const 🔗
Returns true if the an animation is currently active. An animation is active if it was played by calling play() and was not finished yet, or was stopped by calling stop().
This can be used to check whether an animation is currently paused or stopped.
var is_paused = not is_playing() and is_animation_active()
var is_stopped = not is_playing() and not is_animation_active()
Devuelve true si una animación se está reproduciendo actualmente (incluso si speed_scale y/o custom_speed son 0).
void pause() 🔗
Pauses the currently playing animation. The current_animation_position will be kept and calling play() or play_backwards() without arguments or with the same animation name as assigned_animation will resume the animation.
See also stop().
void play(name: StringName = &"", custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false) 🔗
Plays the animation with key name. Custom blend times and speed can be set.
The from_end option only affects when switching to a new animation track, or if the same track but at the start or end. It does not affect resuming playback that was paused in the middle of an animation. If custom_speed is negative and from_end is true, the animation will play backwards (which is equivalent to calling play_backwards()).
The AnimationPlayer keeps track of its current or last played animation with assigned_animation. If this method is called with that same animation name, or with no name parameter, the assigned animation will resume playing if it was paused.
Note: The animation will be updated the next time the AnimationPlayer is processed. If other variables are updated at the same time this is called, they may be updated too early. To perform the update immediately, call advance(0).
void play_backwards(name: StringName = &"", custom_blend: float = -1) 🔗
Reproduce la animación con la clave name al revés.
Este método es una abreviatura de play() con custom_speed = -1.0 y from_end = true, así que consulta su descripción para obtener más información.
void play_section(name: StringName = &"", start_time: float = -1, end_time: float = -1, custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false) 🔗
Reproduce la animación con la clave name y la sección que comienza en start_time y termina en end_time. Véase también play().
Establecer start_time a un valor fuera del rango de la animación significa que se usará el inicio de la animación en su lugar, y establecer end_time a un valor fuera del rango de la animación significa que se usará el final de la animación en su lugar. start_time no puede ser igual a end_time.
void play_section_backwards(name: StringName = &"", start_time: float = -1, end_time: float = -1, custom_blend: float = -1) 🔗
Reproduce la animación con la clave name y la sección que comienza en start_time y termina en end_time en reversa.
Este método es una abreviatura de play_section() con custom_speed = -1.0 y from_end = true, consulta su descripción para más información.
void play_section_with_markers(name: StringName = &"", start_marker: StringName = &"", end_marker: StringName = &"", custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false) 🔗
Reproduce la animación con la clave name y la sección que comienza en el marcador start_marker y termina en end_marker.
Si el marcador de inicio está vacío, la sección comienza desde el principio de la animación. Si el marcador de fin está vacío, la sección termina al final de la animación. Véase también play().
void play_section_with_markers_backwards(name: StringName = &"", start_marker: StringName = &"", end_marker: StringName = &"", custom_blend: float = -1) 🔗
Reproduce la animación con la clave name y la sección que comienza en el marcador start_marker y termina en el marcador end_marker en reversa.
Este método es una abreviatura de play_section_with_markers() con custom_speed = -1.0 y from_end = true, consulta su descripción para más información.
void play_with_capture(name: StringName = &"", duration: float = -1.0, custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false, trans_type: TransitionType = 0, ease_type: EaseType = 0) 🔗
See also AnimationMixer.capture().
You can use this method to use more detailed options for capture than those performed by playback_auto_capture. When playback_auto_capture is false, this method is almost the same as the following:
capture(name, duration, trans_type, ease_type)
play(name, custom_blend, custom_speed, from_end)
If name is blank, it specifies assigned_animation.
If duration is a negative value, the duration is set to the interval between the current position and the first key, when from_end is true, uses the interval between the current position and the last key instead.
Note: The duration takes speed_scale into account, but custom_speed does not, because the capture cache is interpolated with the blend result and the result may contain multiple animations.
void queue(name: StringName) 🔗
Pone en cola una animación para su reproducción una vez que la animación actual y todas las animaciones previamente encoladas hayan terminado.
Nota: Si una animación en bucle se está reproduciendo actualmente, la animación en cola nunca se reproducirá a menos que la animación en bucle se detenga de alguna manera.
void reset_section() 🔗
Restablece la sección actual. No realiza ninguna acción si no se ha definido una sección.
void seek(seconds: float, update: bool = false, update_only: bool = false) 🔗
Busca la animación hasta el punto en el tiempo seconds (en segundos). Si update es true, la animación también se actualiza; de lo contrario, se actualiza en el tiempo de procesado. Los eventos entre el fotograma actual y seconds se omiten.
Si update_only es true, las pistas de reproducción de método/audio/animación no se procesarán.
Nota: Buscar hasta el final de la animación no emite AnimationMixer.animation_finished. Si quieres saltar la animación y emitir la señal, usa AnimationMixer.advance().
void set_blend_time(animation_from: StringName, animation_to: StringName, sec: float) 🔗
Especifica un tiempo de mezcla (en segundos) entre dos animaciones, referenciadas por sus nombres.
void set_method_call_mode(mode: AnimationMethodCallMode) 🔗
Obsoleto: Use AnimationMixer.callback_mode_method instead.
Sets the call mode used for "Call Method" tracks.
void set_process_callback(mode: AnimationProcessCallback) 🔗
Obsoleto: Use AnimationMixer.callback_mode_process instead.
Establece la notificación de proceso en la que se actualizan las animaciones.
void set_root(path: NodePath) 🔗
Obsoleto: Use AnimationMixer.root_node instead.
Establece el nodo desde el cual viajarán las referencias de la ruta de nodos.
void set_section(start_time: float = -1, end_time: float = -1) 🔗
Cambia los tiempos de inicio y fin de la sección que se está reproduciendo. La posición de reproducción actual se limitará dentro de la nueva sección. Véase también play_section().
void set_section_with_markers(start_marker: StringName = &"", end_marker: StringName = &"") 🔗
Cambia los marcadores de inicio y fin de la sección que se está reproduciendo. La posición de reproducción actual se limitará dentro de la nueva sección. Véase también play_section_with_markers().
Si el argumento está vacío, la sección utiliza el principio o el final de la animación. Si ambos están vacíos, significa que la sección no está establecida.
void stop(keep_state: bool = false) 🔗
Stops the currently playing animation. The animation position is reset to 0 and the custom_speed is reset to 1.0. See also pause().
If keep_state is true, the animation state is not updated visually.
Note: The method / audio / animation playback tracks will not be processed by this method.