class_animationplayer.rst 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/AnimationPlayer.xml.
  6. .. _class_AnimationPlayer:
  7. AnimationPlayer
  8. ===============
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Container and player of :ref:`Animation<class_Animation>` resources.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. An animation player is used for general-purpose playback of :ref:`Animation<class_Animation>` resources. It contains a dictionary of animations (referenced by name) and custom blend times between their transitions. Additionally, animations can be played and blended in different channels.
  15. \ **AnimationPlayer** is more suited than :ref:`Tween<class_Tween>` for animations where you know the final values in advance. For example, fading a screen in and out is more easily done with an **AnimationPlayer** node thanks to the animation tools provided by the editor. That particular example can also be implemented with a :ref:`Tween<class_Tween>` node, but it requires doing everything by code.
  16. Updating the target properties of animations occurs at process time.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`Animation tutorial index <../tutorials/animation/index>`
  21. - :doc:`2D Sprite animation <../tutorials/2d/2d_sprite_animation>`
  22. - `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
  23. .. rst-class:: classref-reftable-group
  24. Properties
  25. ----------
  26. .. table::
  27. :widths: auto
  28. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  29. | :ref:`String<class_String>` | :ref:`assigned_animation<class_AnimationPlayer_property_assigned_animation>` | |
  30. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  31. | :ref:`String<class_String>` | :ref:`autoplay<class_AnimationPlayer_property_autoplay>` | ``""`` |
  32. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  33. | :ref:`String<class_String>` | :ref:`current_animation<class_AnimationPlayer_property_current_animation>` | ``""`` |
  34. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  35. | :ref:`float<class_float>` | :ref:`current_animation_length<class_AnimationPlayer_property_current_animation_length>` | |
  36. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  37. | :ref:`float<class_float>` | :ref:`current_animation_position<class_AnimationPlayer_property_current_animation_position>` | |
  38. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  39. | :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` | :ref:`method_call_mode<class_AnimationPlayer_property_method_call_mode>` | ``0`` |
  40. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  41. | :ref:`bool<class_bool>` | :ref:`playback_active<class_AnimationPlayer_property_playback_active>` | |
  42. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  43. | :ref:`float<class_float>` | :ref:`playback_default_blend_time<class_AnimationPlayer_property_playback_default_blend_time>` | ``0.0`` |
  44. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  45. | :ref:`AnimationProcessMode<enum_AnimationPlayer_AnimationProcessMode>` | :ref:`playback_process_mode<class_AnimationPlayer_property_playback_process_mode>` | ``1`` |
  46. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  47. | :ref:`float<class_float>` | :ref:`playback_speed<class_AnimationPlayer_property_playback_speed>` | ``1.0`` |
  48. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  49. | :ref:`bool<class_bool>` | :ref:`reset_on_save<class_AnimationPlayer_property_reset_on_save>` | ``true`` |
  50. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  51. | :ref:`NodePath<class_NodePath>` | :ref:`root_node<class_AnimationPlayer_property_root_node>` | ``NodePath("..")`` |
  52. +------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  53. .. rst-class:: classref-reftable-group
  54. Methods
  55. -------
  56. .. table::
  57. :widths: auto
  58. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`add_animation<class_AnimationPlayer_method_add_animation>` **(** :ref:`String<class_String>` name, :ref:`Animation<class_Animation>` animation **)** |
  60. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`advance<class_AnimationPlayer_method_advance>` **(** :ref:`float<class_float>` delta **)** |
  62. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`String<class_String>` | :ref:`animation_get_next<class_AnimationPlayer_method_animation_get_next>` **(** :ref:`String<class_String>` anim_from **)** |const| |
  64. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`animation_set_next<class_AnimationPlayer_method_animation_set_next>` **(** :ref:`String<class_String>` anim_from, :ref:`String<class_String>` anim_to **)** |
  66. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`clear_caches<class_AnimationPlayer_method_clear_caches>` **(** **)** |
  68. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`clear_queue<class_AnimationPlayer_method_clear_queue>` **(** **)** |
  70. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`String<class_String>` | :ref:`find_animation<class_AnimationPlayer_method_find_animation>` **(** :ref:`Animation<class_Animation>` animation **)** |const| |
  72. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`Animation<class_Animation>` | :ref:`get_animation<class_AnimationPlayer_method_get_animation>` **(** :ref:`String<class_String>` name **)** |const| |
  74. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_animation_list<class_AnimationPlayer_method_get_animation_list>` **(** **)** |const| |
  76. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`float<class_float>` | :ref:`get_blend_time<class_AnimationPlayer_method_get_blend_time>` **(** :ref:`String<class_String>` anim_from, :ref:`String<class_String>` anim_to **)** |const| |
  78. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`float<class_float>` | :ref:`get_playing_speed<class_AnimationPlayer_method_get_playing_speed>` **(** **)** |const| |
  80. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_queue<class_AnimationPlayer_method_get_queue>` **(** **)** |
  82. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`has_animation<class_AnimationPlayer_method_has_animation>` **(** :ref:`String<class_String>` name **)** |const| |
  84. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimationPlayer_method_is_playing>` **(** **)** |const| |
  86. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`play<class_AnimationPlayer_method_play>` **(** :ref:`String<class_String>` name="", :ref:`float<class_float>` custom_blend=-1, :ref:`float<class_float>` custom_speed=1.0, :ref:`bool<class_bool>` from_end=false **)** |
  88. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`play_backwards<class_AnimationPlayer_method_play_backwards>` **(** :ref:`String<class_String>` name="", :ref:`float<class_float>` custom_blend=-1 **)** |
  90. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`queue<class_AnimationPlayer_method_queue>` **(** :ref:`String<class_String>` name **)** |
  92. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`remove_animation<class_AnimationPlayer_method_remove_animation>` **(** :ref:`String<class_String>` name **)** |
  94. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`rename_animation<class_AnimationPlayer_method_rename_animation>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` newname **)** |
  96. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`seek<class_AnimationPlayer_method_seek>` **(** :ref:`float<class_float>` seconds, :ref:`bool<class_bool>` update=false **)** |
  98. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`set_blend_time<class_AnimationPlayer_method_set_blend_time>` **(** :ref:`String<class_String>` anim_from, :ref:`String<class_String>` anim_to, :ref:`float<class_float>` sec **)** |
  100. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`stop<class_AnimationPlayer_method_stop>` **(** :ref:`bool<class_bool>` reset=true **)** |
  102. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. .. rst-class:: classref-section-separator
  104. ----
  105. .. rst-class:: classref-descriptions-group
  106. Signals
  107. -------
  108. .. _class_AnimationPlayer_signal_animation_changed:
  109. .. rst-class:: classref-signal
  110. **animation_changed** **(** :ref:`String<class_String>` old_name, :ref:`String<class_String>` new_name **)**
  111. Emitted when a queued animation plays after the previous animation was finished. See :ref:`queue<class_AnimationPlayer_method_queue>`.
  112. \ **Note:** The signal is not emitted when the animation is changed via :ref:`play<class_AnimationPlayer_method_play>` or from :ref:`AnimationTree<class_AnimationTree>`.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_AnimationPlayer_signal_animation_finished:
  116. .. rst-class:: classref-signal
  117. **animation_finished** **(** :ref:`String<class_String>` anim_name **)**
  118. Notifies when an animation finished playing.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_AnimationPlayer_signal_animation_started:
  122. .. rst-class:: classref-signal
  123. **animation_started** **(** :ref:`String<class_String>` anim_name **)**
  124. Notifies when an animation starts playing.
  125. .. rst-class:: classref-item-separator
  126. ----
  127. .. _class_AnimationPlayer_signal_caches_cleared:
  128. .. rst-class:: classref-signal
  129. **caches_cleared** **(** **)**
  130. Notifies when the caches have been cleared, either automatically, or manually via :ref:`clear_caches<class_AnimationPlayer_method_clear_caches>`.
  131. .. rst-class:: classref-section-separator
  132. ----
  133. .. rst-class:: classref-descriptions-group
  134. Enumerations
  135. ------------
  136. .. _enum_AnimationPlayer_AnimationProcessMode:
  137. .. rst-class:: classref-enumeration
  138. enum **AnimationProcessMode**:
  139. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_PHYSICS:
  140. .. rst-class:: classref-enumeration-constant
  141. :ref:`AnimationProcessMode<enum_AnimationPlayer_AnimationProcessMode>` **ANIMATION_PROCESS_PHYSICS** = ``0``
  142. Process animation during the physics process. This is especially useful when animating physics bodies.
  143. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_IDLE:
  144. .. rst-class:: classref-enumeration-constant
  145. :ref:`AnimationProcessMode<enum_AnimationPlayer_AnimationProcessMode>` **ANIMATION_PROCESS_IDLE** = ``1``
  146. Process animation during the idle process.
  147. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_MANUAL:
  148. .. rst-class:: classref-enumeration-constant
  149. :ref:`AnimationProcessMode<enum_AnimationPlayer_AnimationProcessMode>` **ANIMATION_PROCESS_MANUAL** = ``2``
  150. Do not process animation. Use :ref:`advance<class_AnimationPlayer_method_advance>` to process the animation manually.
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _enum_AnimationPlayer_AnimationMethodCallMode:
  154. .. rst-class:: classref-enumeration
  155. enum **AnimationMethodCallMode**:
  156. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_DEFERRED:
  157. .. rst-class:: classref-enumeration-constant
  158. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_DEFERRED** = ``0``
  159. 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.
  160. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_IMMEDIATE:
  161. .. rst-class:: classref-enumeration-constant
  162. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_IMMEDIATE** = ``1``
  163. Make method calls immediately when reached in the animation.
  164. .. rst-class:: classref-section-separator
  165. ----
  166. .. rst-class:: classref-descriptions-group
  167. Property Descriptions
  168. ---------------------
  169. .. _class_AnimationPlayer_property_assigned_animation:
  170. .. rst-class:: classref-property
  171. :ref:`String<class_String>` **assigned_animation**
  172. .. rst-class:: classref-property-setget
  173. - void **set_assigned_animation** **(** :ref:`String<class_String>` value **)**
  174. - :ref:`String<class_String>` **get_assigned_animation** **(** **)**
  175. If playing, the current animation; otherwise, the animation last played. When set, would change the animation, but would not play it unless currently playing. See also :ref:`current_animation<class_AnimationPlayer_property_current_animation>`.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_AnimationPlayer_property_autoplay:
  179. .. rst-class:: classref-property
  180. :ref:`String<class_String>` **autoplay** = ``""``
  181. .. rst-class:: classref-property-setget
  182. - void **set_autoplay** **(** :ref:`String<class_String>` value **)**
  183. - :ref:`String<class_String>` **get_autoplay** **(** **)**
  184. The name of the animation to play when the scene loads.
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. _class_AnimationPlayer_property_current_animation:
  188. .. rst-class:: classref-property
  189. :ref:`String<class_String>` **current_animation** = ``""``
  190. .. rst-class:: classref-property-setget
  191. - void **set_current_animation** **(** :ref:`String<class_String>` value **)**
  192. - :ref:`String<class_String>` **get_current_animation** **(** **)**
  193. The name 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.
  194. \ **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>`.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_AnimationPlayer_property_current_animation_length:
  198. .. rst-class:: classref-property
  199. :ref:`float<class_float>` **current_animation_length**
  200. .. rst-class:: classref-property-setget
  201. - :ref:`float<class_float>` **get_current_animation_length** **(** **)**
  202. The length (in seconds) of the currently being played animation.
  203. .. rst-class:: classref-item-separator
  204. ----
  205. .. _class_AnimationPlayer_property_current_animation_position:
  206. .. rst-class:: classref-property
  207. :ref:`float<class_float>` **current_animation_position**
  208. .. rst-class:: classref-property-setget
  209. - :ref:`float<class_float>` **get_current_animation_position** **(** **)**
  210. The position (in seconds) of the currently playing animation.
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. _class_AnimationPlayer_property_method_call_mode:
  214. .. rst-class:: classref-property
  215. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **method_call_mode** = ``0``
  216. .. rst-class:: classref-property-setget
  217. - void **set_method_call_mode** **(** :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` value **)**
  218. - :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **get_method_call_mode** **(** **)**
  219. The call mode to use for Call Method tracks.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_AnimationPlayer_property_playback_active:
  223. .. rst-class:: classref-property
  224. :ref:`bool<class_bool>` **playback_active**
  225. .. rst-class:: classref-property-setget
  226. - void **set_active** **(** :ref:`bool<class_bool>` value **)**
  227. - :ref:`bool<class_bool>` **is_active** **(** **)**
  228. If ``true``, updates animations in response to process-related notifications.
  229. .. rst-class:: classref-item-separator
  230. ----
  231. .. _class_AnimationPlayer_property_playback_default_blend_time:
  232. .. rst-class:: classref-property
  233. :ref:`float<class_float>` **playback_default_blend_time** = ``0.0``
  234. .. rst-class:: classref-property-setget
  235. - void **set_default_blend_time** **(** :ref:`float<class_float>` value **)**
  236. - :ref:`float<class_float>` **get_default_blend_time** **(** **)**
  237. The default time in which to blend animations. Ranges from 0 to 4096 with 0.01 precision.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_AnimationPlayer_property_playback_process_mode:
  241. .. rst-class:: classref-property
  242. :ref:`AnimationProcessMode<enum_AnimationPlayer_AnimationProcessMode>` **playback_process_mode** = ``1``
  243. .. rst-class:: classref-property-setget
  244. - void **set_animation_process_mode** **(** :ref:`AnimationProcessMode<enum_AnimationPlayer_AnimationProcessMode>` value **)**
  245. - :ref:`AnimationProcessMode<enum_AnimationPlayer_AnimationProcessMode>` **get_animation_process_mode** **(** **)**
  246. The process notification in which to update animations.
  247. .. rst-class:: classref-item-separator
  248. ----
  249. .. _class_AnimationPlayer_property_playback_speed:
  250. .. rst-class:: classref-property
  251. :ref:`float<class_float>` **playback_speed** = ``1.0``
  252. .. rst-class:: classref-property-setget
  253. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  254. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  255. The speed scaling ratio. For instance, 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.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_AnimationPlayer_property_reset_on_save:
  259. .. rst-class:: classref-property
  260. :ref:`bool<class_bool>` **reset_on_save** = ``true``
  261. .. rst-class:: classref-property-setget
  262. - void **set_reset_on_save_enabled** **(** :ref:`bool<class_bool>` value **)**
  263. - :ref:`bool<class_bool>` **is_reset_on_save_enabled** **(** **)**
  264. This is used by the editor. If set to ``true``, the scene will be saved with the effects of the reset animation applied (as if it had been seeked to time 0), then reverted after saving.
  265. In other words, the saved scene file will contain the "default pose", as defined by the reset animation, if any, with the editor keeping the values that the nodes had before saving.
  266. .. rst-class:: classref-item-separator
  267. ----
  268. .. _class_AnimationPlayer_property_root_node:
  269. .. rst-class:: classref-property
  270. :ref:`NodePath<class_NodePath>` **root_node** = ``NodePath("..")``
  271. .. rst-class:: classref-property-setget
  272. - void **set_root** **(** :ref:`NodePath<class_NodePath>` value **)**
  273. - :ref:`NodePath<class_NodePath>` **get_root** **(** **)**
  274. The node from which node path references will travel.
  275. .. rst-class:: classref-section-separator
  276. ----
  277. .. rst-class:: classref-descriptions-group
  278. Method Descriptions
  279. -------------------
  280. .. _class_AnimationPlayer_method_add_animation:
  281. .. rst-class:: classref-method
  282. :ref:`Error<enum_@GlobalScope_Error>` **add_animation** **(** :ref:`String<class_String>` name, :ref:`Animation<class_Animation>` animation **)**
  283. Adds ``animation`` to the player accessible with the key ``name``.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_AnimationPlayer_method_advance:
  287. .. rst-class:: classref-method
  288. void **advance** **(** :ref:`float<class_float>` delta **)**
  289. 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.
  290. .. rst-class:: classref-item-separator
  291. ----
  292. .. _class_AnimationPlayer_method_animation_get_next:
  293. .. rst-class:: classref-method
  294. :ref:`String<class_String>` **animation_get_next** **(** :ref:`String<class_String>` anim_from **)** |const|
  295. Returns the name of the next animation in the queue.
  296. .. rst-class:: classref-item-separator
  297. ----
  298. .. _class_AnimationPlayer_method_animation_set_next:
  299. .. rst-class:: classref-method
  300. void **animation_set_next** **(** :ref:`String<class_String>` anim_from, :ref:`String<class_String>` anim_to **)**
  301. Triggers the ``anim_to`` animation when the ``anim_from`` animation completes.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_AnimationPlayer_method_clear_caches:
  305. .. rst-class:: classref-method
  306. void **clear_caches** **(** **)**
  307. **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.
  308. .. rst-class:: classref-item-separator
  309. ----
  310. .. _class_AnimationPlayer_method_clear_queue:
  311. .. rst-class:: classref-method
  312. void **clear_queue** **(** **)**
  313. Clears all queued, unplayed animations.
  314. .. rst-class:: classref-item-separator
  315. ----
  316. .. _class_AnimationPlayer_method_find_animation:
  317. .. rst-class:: classref-method
  318. :ref:`String<class_String>` **find_animation** **(** :ref:`Animation<class_Animation>` animation **)** |const|
  319. Returns the name of ``animation`` or an empty string if not found.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_AnimationPlayer_method_get_animation:
  323. .. rst-class:: classref-method
  324. :ref:`Animation<class_Animation>` **get_animation** **(** :ref:`String<class_String>` name **)** |const|
  325. Returns the :ref:`Animation<class_Animation>` with the key ``name``. If the animation does not exist, ``null`` is returned and an error is logged.
  326. .. rst-class:: classref-item-separator
  327. ----
  328. .. _class_AnimationPlayer_method_get_animation_list:
  329. .. rst-class:: classref-method
  330. :ref:`PoolStringArray<class_PoolStringArray>` **get_animation_list** **(** **)** |const|
  331. Returns the list of stored animation names.
  332. .. rst-class:: classref-item-separator
  333. ----
  334. .. _class_AnimationPlayer_method_get_blend_time:
  335. .. rst-class:: classref-method
  336. :ref:`float<class_float>` **get_blend_time** **(** :ref:`String<class_String>` anim_from, :ref:`String<class_String>` anim_to **)** |const|
  337. Gets the blend time (in seconds) between two animations, referenced by their names.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_AnimationPlayer_method_get_playing_speed:
  341. .. rst-class:: classref-method
  342. :ref:`float<class_float>` **get_playing_speed** **(** **)** |const|
  343. Gets the actual playing speed of current animation or 0 if not playing. This speed is the :ref:`playback_speed<class_AnimationPlayer_property_playback_speed>` property multiplied by ``custom_speed`` argument specified when calling the :ref:`play<class_AnimationPlayer_method_play>` method.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_AnimationPlayer_method_get_queue:
  347. .. rst-class:: classref-method
  348. :ref:`PoolStringArray<class_PoolStringArray>` **get_queue** **(** **)**
  349. Returns a list of the animation names that are currently queued to play.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_AnimationPlayer_method_has_animation:
  353. .. rst-class:: classref-method
  354. :ref:`bool<class_bool>` **has_animation** **(** :ref:`String<class_String>` name **)** |const|
  355. Returns ``true`` if the **AnimationPlayer** stores an :ref:`Animation<class_Animation>` with key ``name``.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_AnimationPlayer_method_is_playing:
  359. .. rst-class:: classref-method
  360. :ref:`bool<class_bool>` **is_playing** **(** **)** |const|
  361. Returns ``true`` if playing an animation.
  362. .. rst-class:: classref-item-separator
  363. ----
  364. .. _class_AnimationPlayer_method_play:
  365. .. rst-class:: classref-method
  366. void **play** **(** :ref:`String<class_String>` name="", :ref:`float<class_float>` custom_blend=-1, :ref:`float<class_float>` custom_speed=1.0, :ref:`bool<class_bool>` from_end=false **)**
  367. Plays the animation with key ``name``. Custom blend times and speed can be set. 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>`).
  368. 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, or restart if it was stopped (see :ref:`stop<class_AnimationPlayer_method_stop>` for both pause and stop). If the animation was already playing, it will keep playing.
  369. \ **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)``.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_AnimationPlayer_method_play_backwards:
  373. .. rst-class:: classref-method
  374. void **play_backwards** **(** :ref:`String<class_String>` name="", :ref:`float<class_float>` custom_blend=-1 **)**
  375. Plays the animation with key ``name`` in reverse.
  376. 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.
  377. .. rst-class:: classref-item-separator
  378. ----
  379. .. _class_AnimationPlayer_method_queue:
  380. .. rst-class:: classref-method
  381. void **queue** **(** :ref:`String<class_String>` name **)**
  382. Queues an animation for playback once the current one is done.
  383. \ **Note:** If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.
  384. .. rst-class:: classref-item-separator
  385. ----
  386. .. _class_AnimationPlayer_method_remove_animation:
  387. .. rst-class:: classref-method
  388. void **remove_animation** **(** :ref:`String<class_String>` name **)**
  389. Removes the animation with key ``name``.
  390. .. rst-class:: classref-item-separator
  391. ----
  392. .. _class_AnimationPlayer_method_rename_animation:
  393. .. rst-class:: classref-method
  394. void **rename_animation** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` newname **)**
  395. Renames an existing animation with key ``name`` to ``newname``.
  396. .. rst-class:: classref-item-separator
  397. ----
  398. .. _class_AnimationPlayer_method_seek:
  399. .. rst-class:: classref-method
  400. void **seek** **(** :ref:`float<class_float>` seconds, :ref:`bool<class_bool>` update=false **)**
  401. 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.
  402. \ **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>`.
  403. .. rst-class:: classref-item-separator
  404. ----
  405. .. _class_AnimationPlayer_method_set_blend_time:
  406. .. rst-class:: classref-method
  407. void **set_blend_time** **(** :ref:`String<class_String>` anim_from, :ref:`String<class_String>` anim_to, :ref:`float<class_float>` sec **)**
  408. Specifies a blend time (in seconds) between two animations, referenced by their names.
  409. .. rst-class:: classref-item-separator
  410. ----
  411. .. _class_AnimationPlayer_method_stop:
  412. .. rst-class:: classref-method
  413. void **stop** **(** :ref:`bool<class_bool>` reset=true **)**
  414. Stops or pauses the currently playing animation. If ``reset`` is ``true``, the animation position is reset to ``0`` and the playback speed is reset to ``1.0``.
  415. If ``reset`` is ``false``, 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.
  416. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  417. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  418. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  419. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`