class_animationplayer.rst 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/AnimationPlayer.xml.
  6. .. _class_AnimationPlayer:
  7. AnimationPlayer
  8. ===============
  9. **Inherits:** :ref:`AnimationMixer<class_AnimationMixer>` **<** :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:`String<class_String>` | :ref:`autoplay<class_AnimationPlayer_property_autoplay>` | ``""`` |
  33. +-----------------------------+------------------------------------------------------------------------------------------------+-----------+
  34. | :ref:`String<class_String>` | :ref:`current_animation<class_AnimationPlayer_property_current_animation>` | ``""`` |
  35. +-----------------------------+------------------------------------------------------------------------------------------------+-----------+
  36. | :ref:`float<class_float>` | :ref:`current_animation_length<class_AnimationPlayer_property_current_animation_length>` | |
  37. +-----------------------------+------------------------------------------------------------------------------------------------+-----------+
  38. | :ref:`float<class_float>` | :ref:`current_animation_position<class_AnimationPlayer_property_current_animation_position>` | |
  39. +-----------------------------+------------------------------------------------------------------------------------------------+-----------+
  40. | :ref:`bool<class_bool>` | :ref:`movie_quit_on_finish<class_AnimationPlayer_property_movie_quit_on_finish>` | ``false`` |
  41. +-----------------------------+------------------------------------------------------------------------------------------------+-----------+
  42. | :ref:`float<class_float>` | :ref:`playback_default_blend_time<class_AnimationPlayer_property_playback_default_blend_time>` | ``0.0`` |
  43. +-----------------------------+------------------------------------------------------------------------------------------------+-----------+
  44. | :ref:`float<class_float>` | :ref:`speed_scale<class_AnimationPlayer_property_speed_scale>` | ``1.0`` |
  45. +-----------------------------+------------------------------------------------------------------------------------------------+-----------+
  46. .. rst-class:: classref-reftable-group
  47. Methods
  48. -------
  49. .. table::
  50. :widths: auto
  51. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`StringName<class_StringName>` | :ref:`animation_get_next<class_AnimationPlayer_method_animation_get_next>` **(** :ref:`StringName<class_StringName>` animation_from **)** |const| |
  53. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`animation_set_next<class_AnimationPlayer_method_animation_set_next>` **(** :ref:`StringName<class_StringName>` animation_from, :ref:`StringName<class_StringName>` animation_to **)** |
  55. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`clear_queue<class_AnimationPlayer_method_clear_queue>` **(** **)** |
  57. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`float<class_float>` | :ref:`get_blend_time<class_AnimationPlayer_method_get_blend_time>` **(** :ref:`StringName<class_StringName>` animation_from, :ref:`StringName<class_StringName>` animation_to **)** |const| |
  59. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` | :ref:`get_method_call_mode<class_AnimationPlayer_method_get_method_call_mode>` **(** **)** |const| |
  61. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`float<class_float>` | :ref:`get_playing_speed<class_AnimationPlayer_method_get_playing_speed>` **(** **)** |const| |
  63. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` | :ref:`get_process_callback<class_AnimationPlayer_method_get_process_callback>` **(** **)** |const| |
  65. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_queue<class_AnimationPlayer_method_get_queue>` **(** **)** |
  67. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`NodePath<class_NodePath>` | :ref:`get_root<class_AnimationPlayer_method_get_root>` **(** **)** |const| |
  69. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimationPlayer_method_is_playing>` **(** **)** |const| |
  71. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`pause<class_AnimationPlayer_method_pause>` **(** **)** |
  73. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | 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 **)** |
  75. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`play_backwards<class_AnimationPlayer_method_play_backwards>` **(** :ref:`StringName<class_StringName>` name="", :ref:`float<class_float>` custom_blend=-1 **)** |
  77. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`play_with_capture<class_AnimationPlayer_method_play_with_capture>` **(** :ref:`StringName<class_StringName>` name, :ref:`float<class_float>` duration=-1.0, :ref:`float<class_float>` custom_blend=-1, :ref:`float<class_float>` custom_speed=1.0, :ref:`bool<class_bool>` from_end=false, :ref:`TransitionType<enum_Tween_TransitionType>` trans_type=0, :ref:`EaseType<enum_Tween_EaseType>` ease_type=0 **)** |
  79. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`queue<class_AnimationPlayer_method_queue>` **(** :ref:`StringName<class_StringName>` name **)** |
  81. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`seek<class_AnimationPlayer_method_seek>` **(** :ref:`float<class_float>` seconds, :ref:`bool<class_bool>` update=false, :ref:`bool<class_bool>` update_only=false **)** |
  83. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | void | :ref:`set_blend_time<class_AnimationPlayer_method_set_blend_time>` **(** :ref:`StringName<class_StringName>` animation_from, :ref:`StringName<class_StringName>` animation_to, :ref:`float<class_float>` sec **)** |
  85. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | void | :ref:`set_method_call_mode<class_AnimationPlayer_method_set_method_call_mode>` **(** :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` mode **)** |
  87. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | void | :ref:`set_process_callback<class_AnimationPlayer_method_set_process_callback>` **(** :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` mode **)** |
  89. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`set_root<class_AnimationPlayer_method_set_root>` **(** :ref:`NodePath<class_NodePath>` path **)** |
  91. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`stop<class_AnimationPlayer_method_stop>` **(** :ref:`bool<class_bool>` keep_state=false **)** |
  93. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. .. rst-class:: classref-section-separator
  95. ----
  96. .. rst-class:: classref-descriptions-group
  97. Signals
  98. -------
  99. .. _class_AnimationPlayer_signal_animation_changed:
  100. .. rst-class:: classref-signal
  101. **animation_changed** **(** :ref:`StringName<class_StringName>` old_name, :ref:`StringName<class_StringName>` new_name **)**
  102. Emitted when a queued animation plays after the previous animation finished. See also :ref:`queue<class_AnimationPlayer_method_queue>`.
  103. \ **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>`.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_AnimationPlayer_signal_current_animation_changed:
  107. .. rst-class:: classref-signal
  108. **current_animation_changed** **(** :ref:`String<class_String>` name **)**
  109. Emitted when :ref:`current_animation<class_AnimationPlayer_property_current_animation>` changes.
  110. .. rst-class:: classref-section-separator
  111. ----
  112. .. rst-class:: classref-descriptions-group
  113. Enumerations
  114. ------------
  115. .. _enum_AnimationPlayer_AnimationProcessCallback:
  116. .. rst-class:: classref-enumeration
  117. enum **AnimationProcessCallback**:
  118. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_PHYSICS:
  119. .. rst-class:: classref-enumeration-constant
  120. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_PHYSICS** = ``0``
  121. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_PHYSICS<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_PROCESS_PHYSICS>`.
  122. .. container:: contribute
  123. There is currently no description for this enum. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  124. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_IDLE:
  125. .. rst-class:: classref-enumeration-constant
  126. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_IDLE** = ``1``
  127. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_IDLE<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_PROCESS_IDLE>`.
  128. .. container:: contribute
  129. There is currently no description for this enum. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  130. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_MANUAL:
  131. .. rst-class:: classref-enumeration-constant
  132. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_MANUAL** = ``2``
  133. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_MANUAL<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_PROCESS_MANUAL>`.
  134. .. container:: contribute
  135. There is currently no description for this enum. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _enum_AnimationPlayer_AnimationMethodCallMode:
  139. .. rst-class:: classref-enumeration
  140. enum **AnimationMethodCallMode**:
  141. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_DEFERRED:
  142. .. rst-class:: classref-enumeration-constant
  143. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_DEFERRED** = ``0``
  144. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_METHOD_DEFERRED<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_METHOD_DEFERRED>`.
  145. .. container:: contribute
  146. There is currently no description for this enum. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  147. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_IMMEDIATE:
  148. .. rst-class:: classref-enumeration-constant
  149. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_IMMEDIATE** = ``1``
  150. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_METHOD_IMMEDIATE<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_METHOD_IMMEDIATE>`.
  151. .. container:: contribute
  152. There is currently no description for this enum. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  153. .. rst-class:: classref-section-separator
  154. ----
  155. .. rst-class:: classref-descriptions-group
  156. Property Descriptions
  157. ---------------------
  158. .. _class_AnimationPlayer_property_assigned_animation:
  159. .. rst-class:: classref-property
  160. :ref:`String<class_String>` **assigned_animation**
  161. .. rst-class:: classref-property-setget
  162. - void **set_assigned_animation** **(** :ref:`String<class_String>` value **)**
  163. - :ref:`String<class_String>` **get_assigned_animation** **(** **)**
  164. 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>`.
  165. .. rst-class:: classref-item-separator
  166. ----
  167. .. _class_AnimationPlayer_property_autoplay:
  168. .. rst-class:: classref-property
  169. :ref:`String<class_String>` **autoplay** = ``""``
  170. .. rst-class:: classref-property-setget
  171. - void **set_autoplay** **(** :ref:`String<class_String>` value **)**
  172. - :ref:`String<class_String>` **get_autoplay** **(** **)**
  173. The key of the animation to play when the scene loads.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_AnimationPlayer_property_current_animation:
  177. .. rst-class:: classref-property
  178. :ref:`String<class_String>` **current_animation** = ``""``
  179. .. rst-class:: classref-property-setget
  180. - void **set_current_animation** **(** :ref:`String<class_String>` value **)**
  181. - :ref:`String<class_String>` **get_current_animation** **(** **)**
  182. 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.
  183. \ **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>`.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_AnimationPlayer_property_current_animation_length:
  187. .. rst-class:: classref-property
  188. :ref:`float<class_float>` **current_animation_length**
  189. .. rst-class:: classref-property-setget
  190. - :ref:`float<class_float>` **get_current_animation_length** **(** **)**
  191. The length (in seconds) of the currently playing animation.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_AnimationPlayer_property_current_animation_position:
  195. .. rst-class:: classref-property
  196. :ref:`float<class_float>` **current_animation_position**
  197. .. rst-class:: classref-property-setget
  198. - :ref:`float<class_float>` **get_current_animation_position** **(** **)**
  199. The position (in seconds) of the currently playing animation.
  200. .. rst-class:: classref-item-separator
  201. ----
  202. .. _class_AnimationPlayer_property_movie_quit_on_finish:
  203. .. rst-class:: classref-property
  204. :ref:`bool<class_bool>` **movie_quit_on_finish** = ``false``
  205. .. rst-class:: classref-property-setget
  206. - void **set_movie_quit_on_finish_enabled** **(** :ref:`bool<class_bool>` value **)**
  207. - :ref:`bool<class_bool>` **is_movie_quit_on_finish_enabled** **(** **)**
  208. 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.
  209. \ **Note:** This obeys the same logic as the :ref:`AnimationMixer.animation_finished<class_AnimationMixer_signal_animation_finished>` signal, so it will not quit the engine if the animation is set to be looping.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_AnimationPlayer_property_playback_default_blend_time:
  213. .. rst-class:: classref-property
  214. :ref:`float<class_float>` **playback_default_blend_time** = ``0.0``
  215. .. rst-class:: classref-property-setget
  216. - void **set_default_blend_time** **(** :ref:`float<class_float>` value **)**
  217. - :ref:`float<class_float>` **get_default_blend_time** **(** **)**
  218. The default time in which to blend animations. Ranges from 0 to 4096 with 0.01 precision.
  219. .. rst-class:: classref-item-separator
  220. ----
  221. .. _class_AnimationPlayer_property_speed_scale:
  222. .. rst-class:: classref-property
  223. :ref:`float<class_float>` **speed_scale** = ``1.0``
  224. .. rst-class:: classref-property-setget
  225. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  226. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  227. 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.
  228. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation will not advance.
  229. .. rst-class:: classref-section-separator
  230. ----
  231. .. rst-class:: classref-descriptions-group
  232. Method Descriptions
  233. -------------------
  234. .. _class_AnimationPlayer_method_animation_get_next:
  235. .. rst-class:: classref-method
  236. :ref:`StringName<class_StringName>` **animation_get_next** **(** :ref:`StringName<class_StringName>` animation_from **)** |const|
  237. Returns the key of the animation which is queued to play after the ``animation_from`` animation.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_AnimationPlayer_method_animation_set_next:
  241. .. rst-class:: classref-method
  242. void **animation_set_next** **(** :ref:`StringName<class_StringName>` animation_from, :ref:`StringName<class_StringName>` animation_to **)**
  243. Triggers the ``animation_to`` animation when the ``animation_from`` animation completes.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_AnimationPlayer_method_clear_queue:
  247. .. rst-class:: classref-method
  248. void **clear_queue** **(** **)**
  249. Clears all queued, unplayed animations.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_AnimationPlayer_method_get_blend_time:
  253. .. rst-class:: classref-method
  254. :ref:`float<class_float>` **get_blend_time** **(** :ref:`StringName<class_StringName>` animation_from, :ref:`StringName<class_StringName>` animation_to **)** |const|
  255. Returns the blend time (in seconds) between two animations, referenced by their keys.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_AnimationPlayer_method_get_method_call_mode:
  259. .. rst-class:: classref-method
  260. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **get_method_call_mode** **(** **)** |const|
  261. **Deprecated:** Use :ref:`AnimationMixer.callback_mode_method<class_AnimationMixer_property_callback_mode_method>` instead.
  262. .. container:: contribute
  263. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  264. .. rst-class:: classref-item-separator
  265. ----
  266. .. _class_AnimationPlayer_method_get_playing_speed:
  267. .. rst-class:: classref-method
  268. :ref:`float<class_float>` **get_playing_speed** **(** **)** |const|
  269. 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.
  270. Returns a negative value if the current animation is playing backwards.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_AnimationPlayer_method_get_process_callback:
  274. .. rst-class:: classref-method
  275. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **get_process_callback** **(** **)** |const|
  276. **Deprecated:** Use :ref:`AnimationMixer.callback_mode_process<class_AnimationMixer_property_callback_mode_process>` instead.
  277. .. container:: contribute
  278. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  279. .. rst-class:: classref-item-separator
  280. ----
  281. .. _class_AnimationPlayer_method_get_queue:
  282. .. rst-class:: classref-method
  283. :ref:`PackedStringArray<class_PackedStringArray>` **get_queue** **(** **)**
  284. Returns a list of the animation keys that are currently queued to play.
  285. .. rst-class:: classref-item-separator
  286. ----
  287. .. _class_AnimationPlayer_method_get_root:
  288. .. rst-class:: classref-method
  289. :ref:`NodePath<class_NodePath>` **get_root** **(** **)** |const|
  290. **Deprecated:** Use :ref:`AnimationMixer.root_node<class_AnimationMixer_property_root_node>` instead.
  291. .. container:: contribute
  292. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  293. .. rst-class:: classref-item-separator
  294. ----
  295. .. _class_AnimationPlayer_method_is_playing:
  296. .. rst-class:: classref-method
  297. :ref:`bool<class_bool>` **is_playing** **(** **)** |const|
  298. Returns ``true`` if an animation is currently playing (even if :ref:`speed_scale<class_AnimationPlayer_property_speed_scale>` and/or ``custom_speed`` are ``0``).
  299. .. rst-class:: classref-item-separator
  300. ----
  301. .. _class_AnimationPlayer_method_pause:
  302. .. rst-class:: classref-method
  303. void **pause** **(** **)**
  304. 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.
  305. See also :ref:`stop<class_AnimationPlayer_method_stop>`.
  306. .. rst-class:: classref-item-separator
  307. ----
  308. .. _class_AnimationPlayer_method_play:
  309. .. rst-class:: classref-method
  310. 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 **)**
  311. Plays the animation with key ``name``. Custom blend times and speed can be set.
  312. 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>`).
  313. 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.
  314. \ **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)``.
  315. .. rst-class:: classref-item-separator
  316. ----
  317. .. _class_AnimationPlayer_method_play_backwards:
  318. .. rst-class:: classref-method
  319. void **play_backwards** **(** :ref:`StringName<class_StringName>` name="", :ref:`float<class_float>` custom_blend=-1 **)**
  320. Plays the animation with key ``name`` in reverse.
  321. 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.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_AnimationPlayer_method_play_with_capture:
  325. .. rst-class:: classref-method
  326. void **play_with_capture** **(** :ref:`StringName<class_StringName>` name, :ref:`float<class_float>` duration=-1.0, :ref:`float<class_float>` custom_blend=-1, :ref:`float<class_float>` custom_speed=1.0, :ref:`bool<class_bool>` from_end=false, :ref:`TransitionType<enum_Tween_TransitionType>` trans_type=0, :ref:`EaseType<enum_Tween_EaseType>` ease_type=0 **)**
  327. See :ref:`AnimationMixer.capture<class_AnimationMixer_method_capture>`. It is almost the same as the following:
  328. ::
  329. capture(name, duration, trans_type, ease_type)
  330. play(name, custom_blend, custom_speed, from_end)
  331. If name is blank, it specifies :ref:`assigned_animation<class_AnimationPlayer_property_assigned_animation>`.
  332. 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.
  333. \ **Note:** The ``duration`` takes :ref:`speed_scale<class_AnimationPlayer_property_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.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_AnimationPlayer_method_queue:
  337. .. rst-class:: classref-method
  338. void **queue** **(** :ref:`StringName<class_StringName>` name **)**
  339. Queues an animation for playback once the current one is done.
  340. \ **Note:** If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.
  341. .. rst-class:: classref-item-separator
  342. ----
  343. .. _class_AnimationPlayer_method_seek:
  344. .. rst-class:: classref-method
  345. void **seek** **(** :ref:`float<class_float>` seconds, :ref:`bool<class_bool>` update=false, :ref:`bool<class_bool>` update_only=false **)**
  346. 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.
  347. If ``update_only`` is ``true``, the method / audio / animation playback tracks will not be processed.
  348. \ **Note:** Seeking to the end of the animation doesn't emit :ref:`AnimationMixer.animation_finished<class_AnimationMixer_signal_animation_finished>`. If you want to skip animation and emit the signal, use :ref:`AnimationMixer.advance<class_AnimationMixer_method_advance>`.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_AnimationPlayer_method_set_blend_time:
  352. .. rst-class:: classref-method
  353. void **set_blend_time** **(** :ref:`StringName<class_StringName>` animation_from, :ref:`StringName<class_StringName>` animation_to, :ref:`float<class_float>` sec **)**
  354. Specifies a blend time (in seconds) between two animations, referenced by their keys.
  355. .. rst-class:: classref-item-separator
  356. ----
  357. .. _class_AnimationPlayer_method_set_method_call_mode:
  358. .. rst-class:: classref-method
  359. void **set_method_call_mode** **(** :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` mode **)**
  360. **Deprecated:** Use :ref:`AnimationMixer.callback_mode_method<class_AnimationMixer_property_callback_mode_method>` instead.
  361. .. container:: contribute
  362. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_AnimationPlayer_method_set_process_callback:
  366. .. rst-class:: classref-method
  367. void **set_process_callback** **(** :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` mode **)**
  368. **Deprecated:** Use :ref:`AnimationMixer.callback_mode_process<class_AnimationMixer_property_callback_mode_process>` instead.
  369. .. container:: contribute
  370. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  371. .. rst-class:: classref-item-separator
  372. ----
  373. .. _class_AnimationPlayer_method_set_root:
  374. .. rst-class:: classref-method
  375. void **set_root** **(** :ref:`NodePath<class_NodePath>` path **)**
  376. **Deprecated:** Use :ref:`AnimationMixer.root_node<class_AnimationMixer_property_root_node>` instead.
  377. .. container:: contribute
  378. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_AnimationPlayer_method_stop:
  382. .. rst-class:: classref-method
  383. void **stop** **(** :ref:`bool<class_bool>` keep_state=false **)**
  384. 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>`.
  385. If ``keep_state`` is ``true``, the animation state is not updated visually.
  386. \ **Note:** The method / audio / animation playback tracks will not be processed by this method.
  387. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  388. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  389. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  390. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  391. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  392. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  393. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`