class_animationplayer.rst 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.1/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.1/doc/classes/AnimationPlayer.xml.
  6. .. _class_AnimationPlayer:
  7. AnimationPlayer
  8. ===============
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A node used for animation playback.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. An animation player is used for general-purpose playback of animations. It contains a dictionary of :ref:`AnimationLibrary<class_AnimationLibrary>` resources and custom blend times between animation transitions.
  15. 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.
  16. \ **AnimationPlayer** is better-suited than :ref:`Tween<class_Tween>` for more complex animations, for example ones with non-trivial timings. It can also be used over :ref:`Tween<class_Tween>` if the animation track editor is more convenient than doing it in code.
  17. Updating the target properties of animations occurs at the process frame.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - :doc:`2D Sprite animation <../tutorials/2d/2d_sprite_animation>`
  22. - :doc:`Animation documentation index <../tutorials/animation/index>`
  23. - `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
  24. .. rst-class:: classref-reftable-group
  25. Properties
  26. ----------
  27. .. table::
  28. :widths: auto
  29. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  30. | :ref:`String<class_String>` | :ref:`assigned_animation<class_AnimationPlayer_property_assigned_animation>` | |
  31. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  32. | :ref:`int<class_int>` | :ref:`audio_max_polyphony<class_AnimationPlayer_property_audio_max_polyphony>` | ``32`` |
  33. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  34. | :ref:`String<class_String>` | :ref:`autoplay<class_AnimationPlayer_property_autoplay>` | ``""`` |
  35. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  36. | :ref:`String<class_String>` | :ref:`current_animation<class_AnimationPlayer_property_current_animation>` | ``""`` |
  37. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  38. | :ref:`float<class_float>` | :ref:`current_animation_length<class_AnimationPlayer_property_current_animation_length>` | |
  39. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  40. | :ref:`float<class_float>` | :ref:`current_animation_position<class_AnimationPlayer_property_current_animation_position>` | |
  41. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  42. | :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` | :ref:`method_call_mode<class_AnimationPlayer_property_method_call_mode>` | ``0`` |
  43. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  44. | :ref:`bool<class_bool>` | :ref:`movie_quit_on_finish<class_AnimationPlayer_property_movie_quit_on_finish>` | ``false`` |
  45. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  46. | :ref:`bool<class_bool>` | :ref:`playback_active<class_AnimationPlayer_property_playback_active>` | |
  47. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  48. | :ref:`float<class_float>` | :ref:`playback_default_blend_time<class_AnimationPlayer_property_playback_default_blend_time>` | ``0.0`` |
  49. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  50. | :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` | :ref:`playback_process_mode<class_AnimationPlayer_property_playback_process_mode>` | ``1`` |
  51. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  52. | :ref:`bool<class_bool>` | :ref:`reset_on_save<class_AnimationPlayer_property_reset_on_save>` | ``true`` |
  53. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  54. | :ref:`NodePath<class_NodePath>` | :ref:`root_node<class_AnimationPlayer_property_root_node>` | ``NodePath("..")`` |
  55. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  56. | :ref:`float<class_float>` | :ref:`speed_scale<class_AnimationPlayer_property_speed_scale>` | ``1.0`` |
  57. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  58. .. rst-class:: classref-reftable-group
  59. Methods
  60. -------
  61. .. table::
  62. :widths: auto
  63. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Variant<class_Variant>` | :ref:`_post_process_key_value<class_AnimationPlayer_method__post_process_key_value>` **(** :ref:`Animation<class_Animation>` animation, :ref:`int<class_int>` track, :ref:`Variant<class_Variant>` value, :ref:`Object<class_Object>` object, :ref:`int<class_int>` object_idx **)** |virtual| |const| |
  65. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`add_animation_library<class_AnimationPlayer_method_add_animation_library>` **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationLibrary<class_AnimationLibrary>` library **)** |
  67. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`advance<class_AnimationPlayer_method_advance>` **(** :ref:`float<class_float>` delta **)** |
  69. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`StringName<class_StringName>` | :ref:`animation_get_next<class_AnimationPlayer_method_animation_get_next>` **(** :ref:`StringName<class_StringName>` anim_from **)** |const| |
  71. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`animation_set_next<class_AnimationPlayer_method_animation_set_next>` **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to **)** |
  73. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`clear_caches<class_AnimationPlayer_method_clear_caches>` **(** **)** |
  75. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`clear_queue<class_AnimationPlayer_method_clear_queue>` **(** **)** |
  77. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`StringName<class_StringName>` | :ref:`find_animation<class_AnimationPlayer_method_find_animation>` **(** :ref:`Animation<class_Animation>` animation **)** |const| |
  79. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`StringName<class_StringName>` | :ref:`find_animation_library<class_AnimationPlayer_method_find_animation_library>` **(** :ref:`Animation<class_Animation>` animation **)** |const| |
  81. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`Animation<class_Animation>` | :ref:`get_animation<class_AnimationPlayer_method_get_animation>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  83. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`AnimationLibrary<class_AnimationLibrary>` | :ref:`get_animation_library<class_AnimationPlayer_method_get_animation_library>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  85. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`StringName[]<class_StringName>` | :ref:`get_animation_library_list<class_AnimationPlayer_method_get_animation_library_list>` **(** **)** |const| |
  87. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_animation_list<class_AnimationPlayer_method_get_animation_list>` **(** **)** |const| |
  89. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`float<class_float>` | :ref:`get_blend_time<class_AnimationPlayer_method_get_blend_time>` **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to **)** |const| |
  91. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`float<class_float>` | :ref:`get_playing_speed<class_AnimationPlayer_method_get_playing_speed>` **(** **)** |const| |
  93. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_queue<class_AnimationPlayer_method_get_queue>` **(** **)** |
  95. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`bool<class_bool>` | :ref:`has_animation<class_AnimationPlayer_method_has_animation>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  97. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`bool<class_bool>` | :ref:`has_animation_library<class_AnimationPlayer_method_has_animation_library>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  99. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimationPlayer_method_is_playing>` **(** **)** |const| |
  101. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | void | :ref:`pause<class_AnimationPlayer_method_pause>` **(** **)** |
  103. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | void | :ref:`play<class_AnimationPlayer_method_play>` **(** :ref:`StringName<class_StringName>` name="", :ref:`float<class_float>` custom_blend=-1, :ref:`float<class_float>` custom_speed=1.0, :ref:`bool<class_bool>` from_end=false **)** |
  105. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | void | :ref:`play_backwards<class_AnimationPlayer_method_play_backwards>` **(** :ref:`StringName<class_StringName>` name="", :ref:`float<class_float>` custom_blend=-1 **)** |
  107. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | void | :ref:`queue<class_AnimationPlayer_method_queue>` **(** :ref:`StringName<class_StringName>` name **)** |
  109. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | void | :ref:`remove_animation_library<class_AnimationPlayer_method_remove_animation_library>` **(** :ref:`StringName<class_StringName>` name **)** |
  111. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`rename_animation_library<class_AnimationPlayer_method_rename_animation_library>` **(** :ref:`StringName<class_StringName>` name, :ref:`StringName<class_StringName>` newname **)** |
  113. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | void | :ref:`seek<class_AnimationPlayer_method_seek>` **(** :ref:`float<class_float>` seconds, :ref:`bool<class_bool>` update=false **)** |
  115. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`set_blend_time<class_AnimationPlayer_method_set_blend_time>` **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to, :ref:`float<class_float>` sec **)** |
  117. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | void | :ref:`stop<class_AnimationPlayer_method_stop>` **(** :ref:`bool<class_bool>` keep_state=false **)** |
  119. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. .. rst-class:: classref-section-separator
  121. ----
  122. .. rst-class:: classref-descriptions-group
  123. Signals
  124. -------
  125. .. _class_AnimationPlayer_signal_animation_changed:
  126. .. rst-class:: classref-signal
  127. **animation_changed** **(** :ref:`StringName<class_StringName>` old_name, :ref:`StringName<class_StringName>` new_name **)**
  128. Emitted when a queued animation plays after the previous animation finished. See :ref:`queue<class_AnimationPlayer_method_queue>`.
  129. \ **Note:** The signal is not emitted when the animation is changed via :ref:`play<class_AnimationPlayer_method_play>` or by an :ref:`AnimationTree<class_AnimationTree>`.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_AnimationPlayer_signal_animation_finished:
  133. .. rst-class:: classref-signal
  134. **animation_finished** **(** :ref:`StringName<class_StringName>` anim_name **)**
  135. Notifies when an animation finished playing.
  136. \ **Note:** This signal is not emitted if an animation is looping.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_AnimationPlayer_signal_animation_libraries_updated:
  140. .. rst-class:: classref-signal
  141. **animation_libraries_updated** **(** **)**
  142. Notifies when the animation libraries have changed.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_AnimationPlayer_signal_animation_list_changed:
  146. .. rst-class:: classref-signal
  147. **animation_list_changed** **(** **)**
  148. Notifies when an animation list is changed.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_AnimationPlayer_signal_animation_started:
  152. .. rst-class:: classref-signal
  153. **animation_started** **(** :ref:`StringName<class_StringName>` anim_name **)**
  154. Notifies when an animation starts playing.
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_AnimationPlayer_signal_caches_cleared:
  158. .. rst-class:: classref-signal
  159. **caches_cleared** **(** **)**
  160. Notifies when the caches have been cleared, either automatically, or manually via :ref:`clear_caches<class_AnimationPlayer_method_clear_caches>`.
  161. .. rst-class:: classref-section-separator
  162. ----
  163. .. rst-class:: classref-descriptions-group
  164. Enumerations
  165. ------------
  166. .. _enum_AnimationPlayer_AnimationProcessCallback:
  167. .. rst-class:: classref-enumeration
  168. enum **AnimationProcessCallback**:
  169. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_PHYSICS:
  170. .. rst-class:: classref-enumeration-constant
  171. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_PHYSICS** = ``0``
  172. Process animation during physics frames (see :ref:`Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PHYSICS_PROCESS>`). This is especially useful when animating physics bodies.
  173. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_IDLE:
  174. .. rst-class:: classref-enumeration-constant
  175. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_IDLE** = ``1``
  176. Process animation during process frames (see :ref:`Node.NOTIFICATION_INTERNAL_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PROCESS>`).
  177. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_MANUAL:
  178. .. rst-class:: classref-enumeration-constant
  179. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_MANUAL** = ``2``
  180. Do not process animation. Use :ref:`advance<class_AnimationPlayer_method_advance>` to process the animation manually.
  181. .. rst-class:: classref-item-separator
  182. ----
  183. .. _enum_AnimationPlayer_AnimationMethodCallMode:
  184. .. rst-class:: classref-enumeration
  185. enum **AnimationMethodCallMode**:
  186. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_DEFERRED:
  187. .. rst-class:: classref-enumeration-constant
  188. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_DEFERRED** = ``0``
  189. Batch method calls during the animation process, then do the calls after events are processed. This avoids bugs involving deleting nodes or modifying the AnimationPlayer while playing.
  190. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_IMMEDIATE:
  191. .. rst-class:: classref-enumeration-constant
  192. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_IMMEDIATE** = ``1``
  193. Make method calls immediately when reached in the animation.
  194. .. rst-class:: classref-section-separator
  195. ----
  196. .. rst-class:: classref-descriptions-group
  197. Property Descriptions
  198. ---------------------
  199. .. _class_AnimationPlayer_property_assigned_animation:
  200. .. rst-class:: classref-property
  201. :ref:`String<class_String>` **assigned_animation**
  202. .. rst-class:: classref-property-setget
  203. - void **set_assigned_animation** **(** :ref:`String<class_String>` value **)**
  204. - :ref:`String<class_String>` **get_assigned_animation** **(** **)**
  205. If playing, the current animation's key, otherwise, the animation last played. When set, this changes the animation, but will not play it unless already playing. See also :ref:`current_animation<class_AnimationPlayer_property_current_animation>`.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. _class_AnimationPlayer_property_audio_max_polyphony:
  209. .. rst-class:: classref-property
  210. :ref:`int<class_int>` **audio_max_polyphony** = ``32``
  211. .. rst-class:: classref-property-setget
  212. - void **set_audio_max_polyphony** **(** :ref:`int<class_int>` value **)**
  213. - :ref:`int<class_int>` **get_audio_max_polyphony** **(** **)**
  214. The number of possible simultaneous sounds for each of the assigned AudioStreamPlayers.
  215. For example, if this value is ``32`` and the animation has two audio tracks, the two :ref:`AudioStreamPlayer<class_AudioStreamPlayer>`\ s assigned can play simultaneously up to ``32`` voices each.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_AnimationPlayer_property_autoplay:
  219. .. rst-class:: classref-property
  220. :ref:`String<class_String>` **autoplay** = ``""``
  221. .. rst-class:: classref-property-setget
  222. - void **set_autoplay** **(** :ref:`String<class_String>` value **)**
  223. - :ref:`String<class_String>` **get_autoplay** **(** **)**
  224. The key of the animation to play when the scene loads.
  225. .. rst-class:: classref-item-separator
  226. ----
  227. .. _class_AnimationPlayer_property_current_animation:
  228. .. rst-class:: classref-property
  229. :ref:`String<class_String>` **current_animation** = ``""``
  230. .. rst-class:: classref-property-setget
  231. - void **set_current_animation** **(** :ref:`String<class_String>` value **)**
  232. - :ref:`String<class_String>` **get_current_animation** **(** **)**
  233. The key of the currently playing animation. If no animation is playing, the property's value is an empty string. Changing this value does not restart the animation. See :ref:`play<class_AnimationPlayer_method_play>` for more information on playing animations.
  234. \ **Note:** While this property appears in the Inspector, it's not meant to be edited, and it's not saved in the scene. This property is mainly used to get the currently playing animation, and internally for animation playback tracks. For more information, see :ref:`Animation<class_Animation>`.
  235. .. rst-class:: classref-item-separator
  236. ----
  237. .. _class_AnimationPlayer_property_current_animation_length:
  238. .. rst-class:: classref-property
  239. :ref:`float<class_float>` **current_animation_length**
  240. .. rst-class:: classref-property-setget
  241. - :ref:`float<class_float>` **get_current_animation_length** **(** **)**
  242. The length (in seconds) of the currently playing animation.
  243. .. rst-class:: classref-item-separator
  244. ----
  245. .. _class_AnimationPlayer_property_current_animation_position:
  246. .. rst-class:: classref-property
  247. :ref:`float<class_float>` **current_animation_position**
  248. .. rst-class:: classref-property-setget
  249. - :ref:`float<class_float>` **get_current_animation_position** **(** **)**
  250. The position (in seconds) of the currently playing animation.
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_AnimationPlayer_property_method_call_mode:
  254. .. rst-class:: classref-property
  255. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **method_call_mode** = ``0``
  256. .. rst-class:: classref-property-setget
  257. - void **set_method_call_mode** **(** :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` value **)**
  258. - :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **get_method_call_mode** **(** **)**
  259. The call mode to use for Call Method tracks.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_AnimationPlayer_property_movie_quit_on_finish:
  263. .. rst-class:: classref-property
  264. :ref:`bool<class_bool>` **movie_quit_on_finish** = ``false``
  265. .. rst-class:: classref-property-setget
  266. - void **set_movie_quit_on_finish_enabled** **(** :ref:`bool<class_bool>` value **)**
  267. - :ref:`bool<class_bool>` **is_movie_quit_on_finish_enabled** **(** **)**
  268. If ``true`` and the engine is running in Movie Maker mode (see :ref:`MovieWriter<class_MovieWriter>`), exits the engine with :ref:`SceneTree.quit<class_SceneTree_method_quit>` as soon as an animation is done playing in this **AnimationPlayer**. A message is printed when the engine quits for this reason.
  269. \ **Note:** This obeys the same logic as the :ref:`animation_finished<class_AnimationPlayer_signal_animation_finished>` signal, so it will not quit the engine if the animation is set to be looping.
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _class_AnimationPlayer_property_playback_active:
  273. .. rst-class:: classref-property
  274. :ref:`bool<class_bool>` **playback_active**
  275. .. rst-class:: classref-property-setget
  276. - void **set_active** **(** :ref:`bool<class_bool>` value **)**
  277. - :ref:`bool<class_bool>` **is_active** **(** **)**
  278. If ``true``, updates animations in response to process-related notifications.
  279. .. rst-class:: classref-item-separator
  280. ----
  281. .. _class_AnimationPlayer_property_playback_default_blend_time:
  282. .. rst-class:: classref-property
  283. :ref:`float<class_float>` **playback_default_blend_time** = ``0.0``
  284. .. rst-class:: classref-property-setget
  285. - void **set_default_blend_time** **(** :ref:`float<class_float>` value **)**
  286. - :ref:`float<class_float>` **get_default_blend_time** **(** **)**
  287. The default time in which to blend animations. Ranges from 0 to 4096 with 0.01 precision.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_AnimationPlayer_property_playback_process_mode:
  291. .. rst-class:: classref-property
  292. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **playback_process_mode** = ``1``
  293. .. rst-class:: classref-property-setget
  294. - void **set_process_callback** **(** :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` value **)**
  295. - :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **get_process_callback** **(** **)**
  296. The process notification in which to update animations.
  297. .. rst-class:: classref-item-separator
  298. ----
  299. .. _class_AnimationPlayer_property_reset_on_save:
  300. .. rst-class:: classref-property
  301. :ref:`bool<class_bool>` **reset_on_save** = ``true``
  302. .. rst-class:: classref-property-setget
  303. - void **set_reset_on_save_enabled** **(** :ref:`bool<class_bool>` value **)**
  304. - :ref:`bool<class_bool>` **is_reset_on_save_enabled** **(** **)**
  305. This is used by the editor. If set to ``true``, the scene will be saved with the effects of the reset animation (the animation with the key ``"RESET"``) applied as if it had been seeked to time 0, with the editor keeping the values that the scene had before saving.
  306. This makes it more convenient to preview and edit animations in the editor, as changes to the scene will not be saved as long as they are set in the reset animation.
  307. .. rst-class:: classref-item-separator
  308. ----
  309. .. _class_AnimationPlayer_property_root_node:
  310. .. rst-class:: classref-property
  311. :ref:`NodePath<class_NodePath>` **root_node** = ``NodePath("..")``
  312. .. rst-class:: classref-property-setget
  313. - void **set_root** **(** :ref:`NodePath<class_NodePath>` value **)**
  314. - :ref:`NodePath<class_NodePath>` **get_root** **(** **)**
  315. The node from which node path references will travel.
  316. .. rst-class:: classref-item-separator
  317. ----
  318. .. _class_AnimationPlayer_property_speed_scale:
  319. .. rst-class:: classref-property
  320. :ref:`float<class_float>` **speed_scale** = ``1.0``
  321. .. rst-class:: classref-property-setget
  322. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  323. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  324. 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.
  325. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation will not advance.
  326. .. rst-class:: classref-section-separator
  327. ----
  328. .. rst-class:: classref-descriptions-group
  329. Method Descriptions
  330. -------------------
  331. .. _class_AnimationPlayer_method__post_process_key_value:
  332. .. rst-class:: classref-method
  333. :ref:`Variant<class_Variant>` **_post_process_key_value** **(** :ref:`Animation<class_Animation>` animation, :ref:`int<class_int>` track, :ref:`Variant<class_Variant>` value, :ref:`Object<class_Object>` object, :ref:`int<class_int>` object_idx **)** |virtual| |const|
  334. A virtual function for processing after key getting during playback.
  335. .. rst-class:: classref-item-separator
  336. ----
  337. .. _class_AnimationPlayer_method_add_animation_library:
  338. .. rst-class:: classref-method
  339. :ref:`Error<enum_@GlobalScope_Error>` **add_animation_library** **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationLibrary<class_AnimationLibrary>` library **)**
  340. Adds ``library`` to the animation player, under the key ``name``.
  341. .. rst-class:: classref-item-separator
  342. ----
  343. .. _class_AnimationPlayer_method_advance:
  344. .. rst-class:: classref-method
  345. void **advance** **(** :ref:`float<class_float>` delta **)**
  346. Shifts position in the animation timeline and immediately updates the animation. ``delta`` is the time in seconds to shift. Events between the current frame and ``delta`` are handled.
  347. .. rst-class:: classref-item-separator
  348. ----
  349. .. _class_AnimationPlayer_method_animation_get_next:
  350. .. rst-class:: classref-method
  351. :ref:`StringName<class_StringName>` **animation_get_next** **(** :ref:`StringName<class_StringName>` anim_from **)** |const|
  352. Returns the key of the animation which is queued to play after the ``anim_from`` animation.
  353. .. rst-class:: classref-item-separator
  354. ----
  355. .. _class_AnimationPlayer_method_animation_set_next:
  356. .. rst-class:: classref-method
  357. void **animation_set_next** **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to **)**
  358. Triggers the ``anim_to`` animation when the ``anim_from`` animation completes.
  359. .. rst-class:: classref-item-separator
  360. ----
  361. .. _class_AnimationPlayer_method_clear_caches:
  362. .. rst-class:: classref-method
  363. void **clear_caches** **(** **)**
  364. **AnimationPlayer** caches animated nodes. It may not notice if a node disappears; :ref:`clear_caches<class_AnimationPlayer_method_clear_caches>` forces it to update the cache again.
  365. .. rst-class:: classref-item-separator
  366. ----
  367. .. _class_AnimationPlayer_method_clear_queue:
  368. .. rst-class:: classref-method
  369. void **clear_queue** **(** **)**
  370. Clears all queued, unplayed animations.
  371. .. rst-class:: classref-item-separator
  372. ----
  373. .. _class_AnimationPlayer_method_find_animation:
  374. .. rst-class:: classref-method
  375. :ref:`StringName<class_StringName>` **find_animation** **(** :ref:`Animation<class_Animation>` animation **)** |const|
  376. Returns the key of ``animation`` or an empty :ref:`StringName<class_StringName>` if not found.
  377. .. rst-class:: classref-item-separator
  378. ----
  379. .. _class_AnimationPlayer_method_find_animation_library:
  380. .. rst-class:: classref-method
  381. :ref:`StringName<class_StringName>` **find_animation_library** **(** :ref:`Animation<class_Animation>` animation **)** |const|
  382. Returns the key for the :ref:`AnimationLibrary<class_AnimationLibrary>` that contains ``animation`` or an empty :ref:`StringName<class_StringName>` if not found.
  383. .. rst-class:: classref-item-separator
  384. ----
  385. .. _class_AnimationPlayer_method_get_animation:
  386. .. rst-class:: classref-method
  387. :ref:`Animation<class_Animation>` **get_animation** **(** :ref:`StringName<class_StringName>` name **)** |const|
  388. Returns the :ref:`Animation<class_Animation>` with the key ``name``. If the animation does not exist, ``null`` is returned and an error is logged.
  389. .. rst-class:: classref-item-separator
  390. ----
  391. .. _class_AnimationPlayer_method_get_animation_library:
  392. .. rst-class:: classref-method
  393. :ref:`AnimationLibrary<class_AnimationLibrary>` **get_animation_library** **(** :ref:`StringName<class_StringName>` name **)** |const|
  394. Returns the first :ref:`AnimationLibrary<class_AnimationLibrary>` with key ``name`` or ``null`` if not found.
  395. To get the **AnimationPlayer**'s global animation library, use ``get_animation_library("")``.
  396. .. rst-class:: classref-item-separator
  397. ----
  398. .. _class_AnimationPlayer_method_get_animation_library_list:
  399. .. rst-class:: classref-method
  400. :ref:`StringName[]<class_StringName>` **get_animation_library_list** **(** **)** |const|
  401. Returns the list of stored library keys.
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_AnimationPlayer_method_get_animation_list:
  405. .. rst-class:: classref-method
  406. :ref:`PackedStringArray<class_PackedStringArray>` **get_animation_list** **(** **)** |const|
  407. Returns the list of stored animation keys.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_AnimationPlayer_method_get_blend_time:
  411. .. rst-class:: classref-method
  412. :ref:`float<class_float>` **get_blend_time** **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to **)** |const|
  413. Returns the blend time (in seconds) between two animations, referenced by their keys.
  414. .. rst-class:: classref-item-separator
  415. ----
  416. .. _class_AnimationPlayer_method_get_playing_speed:
  417. .. rst-class:: classref-method
  418. :ref:`float<class_float>` **get_playing_speed** **(** **)** |const|
  419. Returns the actual playing speed of current animation or ``0`` if not playing. This speed is the :ref:`speed_scale<class_AnimationPlayer_property_speed_scale>` property multiplied by ``custom_speed`` argument specified when calling the :ref:`play<class_AnimationPlayer_method_play>` method.
  420. Returns a negative value if the current animation is playing backwards.
  421. .. rst-class:: classref-item-separator
  422. ----
  423. .. _class_AnimationPlayer_method_get_queue:
  424. .. rst-class:: classref-method
  425. :ref:`PackedStringArray<class_PackedStringArray>` **get_queue** **(** **)**
  426. Returns a list of the animation keys that are currently queued to play.
  427. .. rst-class:: classref-item-separator
  428. ----
  429. .. _class_AnimationPlayer_method_has_animation:
  430. .. rst-class:: classref-method
  431. :ref:`bool<class_bool>` **has_animation** **(** :ref:`StringName<class_StringName>` name **)** |const|
  432. Returns ``true`` if the **AnimationPlayer** stores an :ref:`Animation<class_Animation>` with key ``name``.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_AnimationPlayer_method_has_animation_library:
  436. .. rst-class:: classref-method
  437. :ref:`bool<class_bool>` **has_animation_library** **(** :ref:`StringName<class_StringName>` name **)** |const|
  438. Returns ``true`` if the **AnimationPlayer** stores an :ref:`AnimationLibrary<class_AnimationLibrary>` with key ``name``.
  439. .. rst-class:: classref-item-separator
  440. ----
  441. .. _class_AnimationPlayer_method_is_playing:
  442. .. rst-class:: classref-method
  443. :ref:`bool<class_bool>` **is_playing** **(** **)** |const|
  444. Returns ``true`` if an animation is currently playing (even if :ref:`speed_scale<class_AnimationPlayer_property_speed_scale>` and/or ``custom_speed`` are ``0``).
  445. .. rst-class:: classref-item-separator
  446. ----
  447. .. _class_AnimationPlayer_method_pause:
  448. .. rst-class:: classref-method
  449. void **pause** **(** **)**
  450. Pauses the currently playing animation. The :ref:`current_animation_position<class_AnimationPlayer_property_current_animation_position>` will be kept and calling :ref:`play<class_AnimationPlayer_method_play>` or :ref:`play_backwards<class_AnimationPlayer_method_play_backwards>` without arguments or with the same animation name as :ref:`assigned_animation<class_AnimationPlayer_property_assigned_animation>` will resume the animation.
  451. See also :ref:`stop<class_AnimationPlayer_method_stop>`.
  452. .. rst-class:: classref-item-separator
  453. ----
  454. .. _class_AnimationPlayer_method_play:
  455. .. rst-class:: classref-method
  456. void **play** **(** :ref:`StringName<class_StringName>` name="", :ref:`float<class_float>` custom_blend=-1, :ref:`float<class_float>` custom_speed=1.0, :ref:`bool<class_bool>` from_end=false **)**
  457. Plays the animation with key ``name``. Custom blend times and speed can be set.
  458. 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 :ref:`play_backwards<class_AnimationPlayer_method_play_backwards>`).
  459. The **AnimationPlayer** keeps track of its current or last played animation with :ref:`assigned_animation<class_AnimationPlayer_property_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.
  460. \ **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)``.
  461. .. rst-class:: classref-item-separator
  462. ----
  463. .. _class_AnimationPlayer_method_play_backwards:
  464. .. rst-class:: classref-method
  465. void **play_backwards** **(** :ref:`StringName<class_StringName>` name="", :ref:`float<class_float>` custom_blend=-1 **)**
  466. Plays the animation with key ``name`` in reverse.
  467. This method is a shorthand for :ref:`play<class_AnimationPlayer_method_play>` with ``custom_speed = -1.0`` and ``from_end = true``, so see its description for more information.
  468. .. rst-class:: classref-item-separator
  469. ----
  470. .. _class_AnimationPlayer_method_queue:
  471. .. rst-class:: classref-method
  472. void **queue** **(** :ref:`StringName<class_StringName>` name **)**
  473. Queues an animation for playback once the current one is done.
  474. \ **Note:** If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.
  475. .. rst-class:: classref-item-separator
  476. ----
  477. .. _class_AnimationPlayer_method_remove_animation_library:
  478. .. rst-class:: classref-method
  479. void **remove_animation_library** **(** :ref:`StringName<class_StringName>` name **)**
  480. Removes the :ref:`AnimationLibrary<class_AnimationLibrary>` associated with the key ``name``.
  481. .. rst-class:: classref-item-separator
  482. ----
  483. .. _class_AnimationPlayer_method_rename_animation_library:
  484. .. rst-class:: classref-method
  485. void **rename_animation_library** **(** :ref:`StringName<class_StringName>` name, :ref:`StringName<class_StringName>` newname **)**
  486. Moves the :ref:`AnimationLibrary<class_AnimationLibrary>` associated with the key ``name`` to the key ``newname``.
  487. .. rst-class:: classref-item-separator
  488. ----
  489. .. _class_AnimationPlayer_method_seek:
  490. .. rst-class:: classref-method
  491. void **seek** **(** :ref:`float<class_float>` seconds, :ref:`bool<class_bool>` update=false **)**
  492. Seeks the animation to the ``seconds`` point in time (in seconds). If ``update`` is ``true``, the animation updates too, otherwise it updates at process time. Events between the current frame and ``seconds`` are skipped.
  493. \ **Note:** Seeking to the end of the animation doesn't emit :ref:`animation_finished<class_AnimationPlayer_signal_animation_finished>`. If you want to skip animation and emit the signal, use :ref:`advance<class_AnimationPlayer_method_advance>`.
  494. .. rst-class:: classref-item-separator
  495. ----
  496. .. _class_AnimationPlayer_method_set_blend_time:
  497. .. rst-class:: classref-method
  498. void **set_blend_time** **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to, :ref:`float<class_float>` sec **)**
  499. Specifies a blend time (in seconds) between two animations, referenced by their keys.
  500. .. rst-class:: classref-item-separator
  501. ----
  502. .. _class_AnimationPlayer_method_stop:
  503. .. rst-class:: classref-method
  504. void **stop** **(** :ref:`bool<class_bool>` keep_state=false **)**
  505. 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<class_AnimationPlayer_method_pause>`.
  506. If ``keep_state`` is ``true``, the animation state is not updated visually.
  507. \ **Note:** The method / audio / animation playback tracks will not be processed by this method.
  508. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  509. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  510. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  511. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  512. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  513. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  514. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`