:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/AnimatedSprite3D.xml. .. _class_AnimatedSprite3D: AnimatedSprite3D ================ **Inherits:** :ref:`SpriteBase3D` **<** :ref:`GeometryInstance3D` **<** :ref:`VisualInstance3D` **<** :ref:`Node3D` **<** :ref:`Node` **<** :ref:`Object` 2D sprite node in 3D world, that can use multiple 2D textures for animation. .. rst-class:: classref-introduction-group Description ----------- **AnimatedSprite3D** is similar to the :ref:`Sprite3D` node, except it carries multiple textures as animation :ref:`sprite_frames`. Animations are created using a :ref:`SpriteFrames` resource, which allows you to import image files (or a folder containing said files) to provide the animation frames for the sprite. The :ref:`SpriteFrames` resource can be configured in the editor via the SpriteFrames bottom panel. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`2D Sprite animation (also applies to 3D) <../tutorials/2d/2d_sprite_animation>` .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-----------------------------------------+-----------------------------------------------------------------------+----------------+ | :ref:`StringName` | :ref:`animation` | ``&"default"`` | +-----------------------------------------+-----------------------------------------------------------------------+----------------+ | :ref:`String` | :ref:`autoplay` | ``""`` | +-----------------------------------------+-----------------------------------------------------------------------+----------------+ | :ref:`int` | :ref:`frame` | ``0`` | +-----------------------------------------+-----------------------------------------------------------------------+----------------+ | :ref:`float` | :ref:`frame_progress` | ``0.0`` | +-----------------------------------------+-----------------------------------------------------------------------+----------------+ | :ref:`float` | :ref:`speed_scale` | ``1.0`` | +-----------------------------------------+-----------------------------------------------------------------------+----------------+ | :ref:`SpriteFrames` | :ref:`sprite_frames` | | +-----------------------------------------+-----------------------------------------------------------------------+----------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_playing_speed`\ (\ ) |const| | +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_playing`\ (\ ) |const| | +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`pause`\ (\ ) | +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`play`\ (\ name\: :ref:`StringName` = &"", custom_speed\: :ref:`float` = 1.0, from_end\: :ref:`bool` = false\ ) | +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`play_backwards`\ (\ name\: :ref:`StringName` = &""\ ) | +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_frame_and_progress`\ (\ frame\: :ref:`int`, progress\: :ref:`float`\ ) | +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`stop`\ (\ ) | +---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Signals ------- .. _class_AnimatedSprite3D_signal_animation_changed: .. rst-class:: classref-signal **animation_changed**\ (\ ) :ref:`🔗` Emitted when :ref:`animation` changes. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_signal_animation_finished: .. rst-class:: classref-signal **animation_finished**\ (\ ) :ref:`🔗` Emitted when the animation reaches the end, or the start if it is played in reverse. When the animation finishes, it pauses the playback. \ **Note:** This signal is not emitted if an animation is looping. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_signal_animation_looped: .. rst-class:: classref-signal **animation_looped**\ (\ ) :ref:`🔗` Emitted when the animation loops. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_signal_frame_changed: .. rst-class:: classref-signal **frame_changed**\ (\ ) :ref:`🔗` Emitted when :ref:`frame` changes. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_signal_sprite_frames_changed: .. rst-class:: classref-signal **sprite_frames_changed**\ (\ ) :ref:`🔗` Emitted when :ref:`sprite_frames` changes. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_AnimatedSprite3D_property_animation: .. rst-class:: classref-property :ref:`StringName` **animation** = ``&"default"`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_animation**\ (\ value\: :ref:`StringName`\ ) - :ref:`StringName` **get_animation**\ (\ ) The current animation from the :ref:`sprite_frames` resource. If this value is changed, the :ref:`frame` counter and the :ref:`frame_progress` are reset. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_property_autoplay: .. rst-class:: classref-property :ref:`String` **autoplay** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_autoplay**\ (\ value\: :ref:`String`\ ) - :ref:`String` **get_autoplay**\ (\ ) The key of the animation to play when the scene loads. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_property_frame: .. rst-class:: classref-property :ref:`int` **frame** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_frame**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_frame**\ (\ ) The displayed animation frame's index. Setting this property also resets :ref:`frame_progress`. If this is not desired, use :ref:`set_frame_and_progress()`. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_property_frame_progress: .. rst-class:: classref-property :ref:`float` **frame_progress** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_frame_progress**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_frame_progress**\ (\ ) The progress value between ``0.0`` and ``1.0`` until the current frame transitions to the next frame. If the animation is playing backwards, the value transitions from ``1.0`` to ``0.0``. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_property_speed_scale: .. rst-class:: classref-property :ref:`float` **speed_scale** = ``1.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_speed_scale**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_speed_scale**\ (\ ) The speed scaling ratio. For example, if this value is ``1``, then the animation plays at normal speed. If it's ``0.5``, then it plays at half speed. If it's ``2``, then it plays at double speed. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation will not advance. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_property_sprite_frames: .. rst-class:: classref-property :ref:`SpriteFrames` **sprite_frames** :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_sprite_frames**\ (\ value\: :ref:`SpriteFrames`\ ) - :ref:`SpriteFrames` **get_sprite_frames**\ (\ ) The :ref:`SpriteFrames` resource containing the animation(s). Allows you the option to load, edit, clear, make unique and save the states of the :ref:`SpriteFrames` resource. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_AnimatedSprite3D_method_get_playing_speed: .. rst-class:: classref-method :ref:`float` **get_playing_speed**\ (\ ) |const| :ref:`🔗` Returns the actual playing speed of current animation or ``0`` if not playing. This speed is the :ref:`speed_scale` property multiplied by ``custom_speed`` argument specified when calling the :ref:`play()` method. Returns a negative value if the current animation is playing backwards. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_method_is_playing: .. rst-class:: classref-method :ref:`bool` **is_playing**\ (\ ) |const| :ref:`🔗` Returns ``true`` if an animation is currently playing (even if :ref:`speed_scale` and/or ``custom_speed`` are ``0``). .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_method_pause: .. rst-class:: classref-method |void| **pause**\ (\ ) :ref:`🔗` Pauses the currently playing animation. The :ref:`frame` and :ref:`frame_progress` will be kept and calling :ref:`play()` or :ref:`play_backwards()` without arguments will resume the animation from the current playback position. See also :ref:`stop()`. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_method_play: .. rst-class:: classref-method |void| **play**\ (\ name\: :ref:`StringName` = &"", custom_speed\: :ref:`float` = 1.0, from_end\: :ref:`bool` = false\ ) :ref:`🔗` Plays the animation with key ``name``. If ``custom_speed`` is negative and ``from_end`` is ``true``, the animation will play backwards (which is equivalent to calling :ref:`play_backwards()`). 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. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_method_play_backwards: .. rst-class:: classref-method |void| **play_backwards**\ (\ name\: :ref:`StringName` = &""\ ) :ref:`🔗` Plays the animation with key ``name`` in reverse. This method is a shorthand for :ref:`play()` with ``custom_speed = -1.0`` and ``from_end = true``, so see its description for more information. .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_method_set_frame_and_progress: .. rst-class:: classref-method |void| **set_frame_and_progress**\ (\ frame\: :ref:`int`, progress\: :ref:`float`\ ) :ref:`🔗` Sets :ref:`frame` and :ref:`frame_progress` to the given values. Unlike setting :ref:`frame`, this method does not reset the :ref:`frame_progress` to ``0.0`` implicitly. \ **Example:** Change the animation while keeping the same :ref:`frame` and :ref:`frame_progress`: .. tabs:: .. code-tab:: gdscript var current_frame = animated_sprite.get_frame() var current_progress = animated_sprite.get_frame_progress() animated_sprite.play("walk_another_skin") animated_sprite.set_frame_and_progress(current_frame, current_progress) .. rst-class:: classref-item-separator ---- .. _class_AnimatedSprite3D_method_stop: .. rst-class:: classref-method |void| **stop**\ (\ ) :ref:`🔗` Stops the currently playing animation. The animation position is reset to ``0`` and the ``custom_speed`` is reset to ``1.0``. See also :ref:`pause()`. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`