class_animationplayer.rst 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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>`\ (\ animation_from\: :ref:`StringName<class_StringName>`\ ) |const| |
  53. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | |void| | :ref:`animation_set_next<class_AnimationPlayer_method_animation_set_next>`\ (\ animation_from\: :ref:`StringName<class_StringName>`, animation_to\: :ref:`StringName<class_StringName>`\ ) |
  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>`\ (\ animation_from\: :ref:`StringName<class_StringName>`, animation_to\: :ref:`StringName<class_StringName>`\ ) |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>`\ (\ name\: :ref:`StringName<class_StringName>` = &"", custom_blend\: :ref:`float<class_float>` = -1, custom_speed\: :ref:`float<class_float>` = 1.0, from_end\: :ref:`bool<class_bool>` = false\ ) |
  75. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | |void| | :ref:`play_backwards<class_AnimationPlayer_method_play_backwards>`\ (\ name\: :ref:`StringName<class_StringName>` = &"", custom_blend\: :ref:`float<class_float>` = -1\ ) |
  77. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | |void| | :ref:`play_with_capture<class_AnimationPlayer_method_play_with_capture>`\ (\ name\: :ref:`StringName<class_StringName>`, duration\: :ref:`float<class_float>` = -1.0, custom_blend\: :ref:`float<class_float>` = -1, custom_speed\: :ref:`float<class_float>` = 1.0, from_end\: :ref:`bool<class_bool>` = false, trans_type\: :ref:`TransitionType<enum_Tween_TransitionType>` = 0, ease_type\: :ref:`EaseType<enum_Tween_EaseType>` = 0\ ) |
  79. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | |void| | :ref:`queue<class_AnimationPlayer_method_queue>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |
  81. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | |void| | :ref:`seek<class_AnimationPlayer_method_seek>`\ (\ seconds\: :ref:`float<class_float>`, update\: :ref:`bool<class_bool>` = false, update_only\: :ref:`bool<class_bool>` = false\ ) |
  83. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | |void| | :ref:`set_blend_time<class_AnimationPlayer_method_set_blend_time>`\ (\ animation_from\: :ref:`StringName<class_StringName>`, animation_to\: :ref:`StringName<class_StringName>`, sec\: :ref:`float<class_float>`\ ) |
  85. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | |void| | :ref:`set_method_call_mode<class_AnimationPlayer_method_set_method_call_mode>`\ (\ mode\: :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>`\ ) |
  87. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | |void| | :ref:`set_process_callback<class_AnimationPlayer_method_set_process_callback>`\ (\ mode\: :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>`\ ) |
  89. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | |void| | :ref:`set_root<class_AnimationPlayer_method_set_root>`\ (\ path\: :ref:`NodePath<class_NodePath>`\ ) |
  91. +--------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | |void| | :ref:`stop<class_AnimationPlayer_method_stop>`\ (\ keep_state\: :ref:`bool<class_bool>` = 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**\ (\ old_name\: :ref:`StringName<class_StringName>`, new_name\: :ref:`StringName<class_StringName>`\ )
  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**\ (\ name\: :ref:`String<class_String>`\ )
  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. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_IDLE:
  123. .. rst-class:: classref-enumeration-constant
  124. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_IDLE** = ``1``
  125. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_IDLE<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_PROCESS_IDLE>`.
  126. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_MANUAL:
  127. .. rst-class:: classref-enumeration-constant
  128. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_MANUAL** = ``2``
  129. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_MANUAL<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_PROCESS_MANUAL>`.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _enum_AnimationPlayer_AnimationMethodCallMode:
  133. .. rst-class:: classref-enumeration
  134. enum **AnimationMethodCallMode**:
  135. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_DEFERRED:
  136. .. rst-class:: classref-enumeration-constant
  137. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_DEFERRED** = ``0``
  138. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_METHOD_DEFERRED<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_METHOD_DEFERRED>`.
  139. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_IMMEDIATE:
  140. .. rst-class:: classref-enumeration-constant
  141. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_IMMEDIATE** = ``1``
  142. **Deprecated:** See :ref:`AnimationMixer.ANIMATION_CALLBACK_MODE_METHOD_IMMEDIATE<class_AnimationMixer_constant_ANIMATION_CALLBACK_MODE_METHOD_IMMEDIATE>`.
  143. .. rst-class:: classref-section-separator
  144. ----
  145. .. rst-class:: classref-descriptions-group
  146. Property Descriptions
  147. ---------------------
  148. .. _class_AnimationPlayer_property_assigned_animation:
  149. .. rst-class:: classref-property
  150. :ref:`String<class_String>` **assigned_animation**
  151. .. rst-class:: classref-property-setget
  152. - |void| **set_assigned_animation**\ (\ value\: :ref:`String<class_String>`\ )
  153. - :ref:`String<class_String>` **get_assigned_animation**\ (\ )
  154. 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>`.
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_AnimationPlayer_property_autoplay:
  158. .. rst-class:: classref-property
  159. :ref:`String<class_String>` **autoplay** = ``""``
  160. .. rst-class:: classref-property-setget
  161. - |void| **set_autoplay**\ (\ value\: :ref:`String<class_String>`\ )
  162. - :ref:`String<class_String>` **get_autoplay**\ (\ )
  163. The key of the animation to play when the scene loads.
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_AnimationPlayer_property_current_animation:
  167. .. rst-class:: classref-property
  168. :ref:`String<class_String>` **current_animation** = ``""``
  169. .. rst-class:: classref-property-setget
  170. - |void| **set_current_animation**\ (\ value\: :ref:`String<class_String>`\ )
  171. - :ref:`String<class_String>` **get_current_animation**\ (\ )
  172. 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.
  173. \ **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>`.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_AnimationPlayer_property_current_animation_length:
  177. .. rst-class:: classref-property
  178. :ref:`float<class_float>` **current_animation_length**
  179. .. rst-class:: classref-property-setget
  180. - :ref:`float<class_float>` **get_current_animation_length**\ (\ )
  181. The length (in seconds) of the currently playing animation.
  182. .. rst-class:: classref-item-separator
  183. ----
  184. .. _class_AnimationPlayer_property_current_animation_position:
  185. .. rst-class:: classref-property
  186. :ref:`float<class_float>` **current_animation_position**
  187. .. rst-class:: classref-property-setget
  188. - :ref:`float<class_float>` **get_current_animation_position**\ (\ )
  189. The position (in seconds) of the currently playing animation.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_AnimationPlayer_property_movie_quit_on_finish:
  193. .. rst-class:: classref-property
  194. :ref:`bool<class_bool>` **movie_quit_on_finish** = ``false``
  195. .. rst-class:: classref-property-setget
  196. - |void| **set_movie_quit_on_finish_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  197. - :ref:`bool<class_bool>` **is_movie_quit_on_finish_enabled**\ (\ )
  198. 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.
  199. \ **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.
  200. .. rst-class:: classref-item-separator
  201. ----
  202. .. _class_AnimationPlayer_property_playback_default_blend_time:
  203. .. rst-class:: classref-property
  204. :ref:`float<class_float>` **playback_default_blend_time** = ``0.0``
  205. .. rst-class:: classref-property-setget
  206. - |void| **set_default_blend_time**\ (\ value\: :ref:`float<class_float>`\ )
  207. - :ref:`float<class_float>` **get_default_blend_time**\ (\ )
  208. The default time in which to blend animations. Ranges from 0 to 4096 with 0.01 precision.
  209. .. rst-class:: classref-item-separator
  210. ----
  211. .. _class_AnimationPlayer_property_speed_scale:
  212. .. rst-class:: classref-property
  213. :ref:`float<class_float>` **speed_scale** = ``1.0``
  214. .. rst-class:: classref-property-setget
  215. - |void| **set_speed_scale**\ (\ value\: :ref:`float<class_float>`\ )
  216. - :ref:`float<class_float>` **get_speed_scale**\ (\ )
  217. 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.
  218. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation will not advance.
  219. .. rst-class:: classref-section-separator
  220. ----
  221. .. rst-class:: classref-descriptions-group
  222. Method Descriptions
  223. -------------------
  224. .. _class_AnimationPlayer_method_animation_get_next:
  225. .. rst-class:: classref-method
  226. :ref:`StringName<class_StringName>` **animation_get_next**\ (\ animation_from\: :ref:`StringName<class_StringName>`\ ) |const|
  227. Returns the key of the animation which is queued to play after the ``animation_from`` animation.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_AnimationPlayer_method_animation_set_next:
  231. .. rst-class:: classref-method
  232. |void| **animation_set_next**\ (\ animation_from\: :ref:`StringName<class_StringName>`, animation_to\: :ref:`StringName<class_StringName>`\ )
  233. Triggers the ``animation_to`` animation when the ``animation_from`` animation completes.
  234. .. rst-class:: classref-item-separator
  235. ----
  236. .. _class_AnimationPlayer_method_clear_queue:
  237. .. rst-class:: classref-method
  238. |void| **clear_queue**\ (\ )
  239. Clears all queued, unplayed animations.
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_AnimationPlayer_method_get_blend_time:
  243. .. rst-class:: classref-method
  244. :ref:`float<class_float>` **get_blend_time**\ (\ animation_from\: :ref:`StringName<class_StringName>`, animation_to\: :ref:`StringName<class_StringName>`\ ) |const|
  245. Returns the blend time (in seconds) between two animations, referenced by their keys.
  246. .. rst-class:: classref-item-separator
  247. ----
  248. .. _class_AnimationPlayer_method_get_method_call_mode:
  249. .. rst-class:: classref-method
  250. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **get_method_call_mode**\ (\ ) |const|
  251. **Deprecated:** Use :ref:`AnimationMixer.callback_mode_method<class_AnimationMixer_property_callback_mode_method>` instead.
  252. Returns the call mode used for "Call Method" tracks.
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _class_AnimationPlayer_method_get_playing_speed:
  256. .. rst-class:: classref-method
  257. :ref:`float<class_float>` **get_playing_speed**\ (\ ) |const|
  258. 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.
  259. Returns a negative value if the current animation is playing backwards.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_AnimationPlayer_method_get_process_callback:
  263. .. rst-class:: classref-method
  264. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **get_process_callback**\ (\ ) |const|
  265. **Deprecated:** Use :ref:`AnimationMixer.callback_mode_process<class_AnimationMixer_property_callback_mode_process>` instead.
  266. Returns the process notification in which to update animations.
  267. .. rst-class:: classref-item-separator
  268. ----
  269. .. _class_AnimationPlayer_method_get_queue:
  270. .. rst-class:: classref-method
  271. :ref:`PackedStringArray<class_PackedStringArray>` **get_queue**\ (\ )
  272. Returns a list of the animation keys that are currently queued to play.
  273. .. rst-class:: classref-item-separator
  274. ----
  275. .. _class_AnimationPlayer_method_get_root:
  276. .. rst-class:: classref-method
  277. :ref:`NodePath<class_NodePath>` **get_root**\ (\ ) |const|
  278. **Deprecated:** Use :ref:`AnimationMixer.root_node<class_AnimationMixer_property_root_node>` instead.
  279. Returns the node which node path references will travel from.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_AnimationPlayer_method_is_playing:
  283. .. rst-class:: classref-method
  284. :ref:`bool<class_bool>` **is_playing**\ (\ ) |const|
  285. Returns ``true`` if an animation is currently playing (even if :ref:`speed_scale<class_AnimationPlayer_property_speed_scale>` and/or ``custom_speed`` are ``0``).
  286. .. rst-class:: classref-item-separator
  287. ----
  288. .. _class_AnimationPlayer_method_pause:
  289. .. rst-class:: classref-method
  290. |void| **pause**\ (\ )
  291. 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.
  292. See also :ref:`stop<class_AnimationPlayer_method_stop>`.
  293. .. rst-class:: classref-item-separator
  294. ----
  295. .. _class_AnimationPlayer_method_play:
  296. .. rst-class:: classref-method
  297. |void| **play**\ (\ name\: :ref:`StringName<class_StringName>` = &"", custom_blend\: :ref:`float<class_float>` = -1, custom_speed\: :ref:`float<class_float>` = 1.0, from_end\: :ref:`bool<class_bool>` = false\ )
  298. Plays the animation with key ``name``. Custom blend times and speed can be set.
  299. 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>`).
  300. 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.
  301. \ **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)``.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_AnimationPlayer_method_play_backwards:
  305. .. rst-class:: classref-method
  306. |void| **play_backwards**\ (\ name\: :ref:`StringName<class_StringName>` = &"", custom_blend\: :ref:`float<class_float>` = -1\ )
  307. Plays the animation with key ``name`` in reverse.
  308. 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.
  309. .. rst-class:: classref-item-separator
  310. ----
  311. .. _class_AnimationPlayer_method_play_with_capture:
  312. .. rst-class:: classref-method
  313. |void| **play_with_capture**\ (\ name\: :ref:`StringName<class_StringName>`, duration\: :ref:`float<class_float>` = -1.0, custom_blend\: :ref:`float<class_float>` = -1, custom_speed\: :ref:`float<class_float>` = 1.0, from_end\: :ref:`bool<class_bool>` = false, trans_type\: :ref:`TransitionType<enum_Tween_TransitionType>` = 0, ease_type\: :ref:`EaseType<enum_Tween_EaseType>` = 0\ )
  314. See :ref:`AnimationMixer.capture<class_AnimationMixer_method_capture>`. It is almost the same as the following:
  315. ::
  316. capture(name, duration, trans_type, ease_type)
  317. play(name, custom_blend, custom_speed, from_end)
  318. If name is blank, it specifies :ref:`assigned_animation<class_AnimationPlayer_property_assigned_animation>`.
  319. 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.
  320. \ **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.
  321. .. rst-class:: classref-item-separator
  322. ----
  323. .. _class_AnimationPlayer_method_queue:
  324. .. rst-class:: classref-method
  325. |void| **queue**\ (\ name\: :ref:`StringName<class_StringName>`\ )
  326. Queues an animation for playback once the current one is done.
  327. \ **Note:** If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_AnimationPlayer_method_seek:
  331. .. rst-class:: classref-method
  332. |void| **seek**\ (\ seconds\: :ref:`float<class_float>`, update\: :ref:`bool<class_bool>` = false, update_only\: :ref:`bool<class_bool>` = false\ )
  333. 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.
  334. If ``update_only`` is ``true``, the method / audio / animation playback tracks will not be processed.
  335. \ **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>`.
  336. .. rst-class:: classref-item-separator
  337. ----
  338. .. _class_AnimationPlayer_method_set_blend_time:
  339. .. rst-class:: classref-method
  340. |void| **set_blend_time**\ (\ animation_from\: :ref:`StringName<class_StringName>`, animation_to\: :ref:`StringName<class_StringName>`, sec\: :ref:`float<class_float>`\ )
  341. Specifies a blend time (in seconds) between two animations, referenced by their keys.
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_AnimationPlayer_method_set_method_call_mode:
  345. .. rst-class:: classref-method
  346. |void| **set_method_call_mode**\ (\ mode\: :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>`\ )
  347. **Deprecated:** Use :ref:`AnimationMixer.callback_mode_method<class_AnimationMixer_property_callback_mode_method>` instead.
  348. Sets the call mode used for "Call Method" tracks.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_AnimationPlayer_method_set_process_callback:
  352. .. rst-class:: classref-method
  353. |void| **set_process_callback**\ (\ mode\: :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>`\ )
  354. **Deprecated:** Use :ref:`AnimationMixer.callback_mode_process<class_AnimationMixer_property_callback_mode_process>` instead.
  355. Sets the process notification in which to update animations.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_AnimationPlayer_method_set_root:
  359. .. rst-class:: classref-method
  360. |void| **set_root**\ (\ path\: :ref:`NodePath<class_NodePath>`\ )
  361. **Deprecated:** Use :ref:`AnimationMixer.root_node<class_AnimationMixer_property_root_node>` instead.
  362. Sets the node which node path references will travel from.
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_AnimationPlayer_method_stop:
  366. .. rst-class:: classref-method
  367. |void| **stop**\ (\ keep_state\: :ref:`bool<class_bool>` = false\ )
  368. 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>`.
  369. If ``keep_state`` is ``true``, the animation state is not updated visually.
  370. \ **Note:** The method / audio / animation playback tracks will not be processed by this method.
  371. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  372. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  373. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  374. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  375. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  376. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  377. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  378. .. |void| replace:: :abbr:`void (No return value.)`