class_animationplayer.rst 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  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:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. 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 :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 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>`, but it requires doing everything by code.
  17. Updating the target properties of animations occurs at process time.
  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:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` | :ref:`method_call_mode<class_AnimationPlayer_property_method_call_mode>` | ``0`` |
  41. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  42. | :ref:`bool<class_bool>` | :ref:`movie_quit_on_finish<class_AnimationPlayer_property_movie_quit_on_finish>` | ``false`` |
  43. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  44. | :ref:`bool<class_bool>` | :ref:`playback_active<class_AnimationPlayer_property_playback_active>` | |
  45. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  46. | :ref:`float<class_float>` | :ref:`playback_default_blend_time<class_AnimationPlayer_property_playback_default_blend_time>` | ``0.0`` |
  47. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  48. | :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` | :ref:`playback_process_mode<class_AnimationPlayer_property_playback_process_mode>` | ``1`` |
  49. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  50. | :ref:`bool<class_bool>` | :ref:`reset_on_save<class_AnimationPlayer_property_reset_on_save>` | ``true`` |
  51. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  52. | :ref:`NodePath<class_NodePath>` | :ref:`root_node<class_AnimationPlayer_property_root_node>` | ``NodePath("..")`` |
  53. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  54. | :ref:`float<class_float>` | :ref:`speed_scale<class_AnimationPlayer_property_speed_scale>` | ``1.0`` |
  55. +--------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------+--------------------+
  56. .. rst-class:: classref-reftable-group
  57. Methods
  58. -------
  59. .. table::
  60. :widths: auto
  61. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Variant<class_Variant>` | :ref:`_post_process_key_value<class_AnimationPlayer_method__post_process_key_value>` **(** :ref:`Animation<class_Animation>` animation, :ref:`int<class_int>` track, :ref:`Variant<class_Variant>` value, :ref:`Object<class_Object>` object, :ref:`int<class_int>` object_idx **)** |virtual| |const| |
  63. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`add_animation_library<class_AnimationPlayer_method_add_animation_library>` **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationLibrary<class_AnimationLibrary>` library **)** |
  65. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`advance<class_AnimationPlayer_method_advance>` **(** :ref:`float<class_float>` delta **)** |
  67. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`StringName<class_StringName>` | :ref:`animation_get_next<class_AnimationPlayer_method_animation_get_next>` **(** :ref:`StringName<class_StringName>` anim_from **)** |const| |
  69. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`animation_set_next<class_AnimationPlayer_method_animation_set_next>` **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to **)** |
  71. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`clear_caches<class_AnimationPlayer_method_clear_caches>` **(** **)** |
  73. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`clear_queue<class_AnimationPlayer_method_clear_queue>` **(** **)** |
  75. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`StringName<class_StringName>` | :ref:`find_animation<class_AnimationPlayer_method_find_animation>` **(** :ref:`Animation<class_Animation>` animation **)** |const| |
  77. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`StringName<class_StringName>` | :ref:`find_animation_library<class_AnimationPlayer_method_find_animation_library>` **(** :ref:`Animation<class_Animation>` animation **)** |const| |
  79. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Animation<class_Animation>` | :ref:`get_animation<class_AnimationPlayer_method_get_animation>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  81. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`AnimationLibrary<class_AnimationLibrary>` | :ref:`get_animation_library<class_AnimationPlayer_method_get_animation_library>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  83. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`StringName[]<class_StringName>` | :ref:`get_animation_library_list<class_AnimationPlayer_method_get_animation_library_list>` **(** **)** |const| |
  85. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_animation_list<class_AnimationPlayer_method_get_animation_list>` **(** **)** |const| |
  87. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`float<class_float>` | :ref:`get_blend_time<class_AnimationPlayer_method_get_blend_time>` **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to **)** |const| |
  89. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`float<class_float>` | :ref:`get_playing_speed<class_AnimationPlayer_method_get_playing_speed>` **(** **)** |const| |
  91. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_queue<class_AnimationPlayer_method_get_queue>` **(** **)** |
  93. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`bool<class_bool>` | :ref:`has_animation<class_AnimationPlayer_method_has_animation>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  95. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`bool<class_bool>` | :ref:`has_animation_library<class_AnimationPlayer_method_has_animation_library>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  97. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimationPlayer_method_is_playing>` **(** **)** |const| |
  99. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | void | :ref:`pause<class_AnimationPlayer_method_pause>` **(** **)** |
  101. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | 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 **)** |
  103. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | void | :ref:`play_backwards<class_AnimationPlayer_method_play_backwards>` **(** :ref:`StringName<class_StringName>` name="", :ref:`float<class_float>` custom_blend=-1 **)** |
  105. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | void | :ref:`queue<class_AnimationPlayer_method_queue>` **(** :ref:`StringName<class_StringName>` name **)** |
  107. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | void | :ref:`remove_animation_library<class_AnimationPlayer_method_remove_animation_library>` **(** :ref:`StringName<class_StringName>` name **)** |
  109. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | void | :ref:`rename_animation_library<class_AnimationPlayer_method_rename_animation_library>` **(** :ref:`StringName<class_StringName>` name, :ref:`StringName<class_StringName>` newname **)** |
  111. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`seek<class_AnimationPlayer_method_seek>` **(** :ref:`float<class_float>` seconds, :ref:`bool<class_bool>` update=false **)** |
  113. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | void | :ref:`set_blend_time<class_AnimationPlayer_method_set_blend_time>` **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to, :ref:`float<class_float>` sec **)** |
  115. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`stop<class_AnimationPlayer_method_stop>` **(** :ref:`bool<class_bool>` keep_state=false **)** |
  117. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. .. rst-class:: classref-section-separator
  119. ----
  120. .. rst-class:: classref-descriptions-group
  121. Signals
  122. -------
  123. .. _class_AnimationPlayer_signal_animation_changed:
  124. .. rst-class:: classref-signal
  125. **animation_changed** **(** :ref:`StringName<class_StringName>` old_name, :ref:`StringName<class_StringName>` new_name **)**
  126. Emitted when a queued animation plays after the previous animation finished. See :ref:`queue<class_AnimationPlayer_method_queue>`.
  127. \ **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>`.
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_AnimationPlayer_signal_animation_finished:
  131. .. rst-class:: classref-signal
  132. **animation_finished** **(** :ref:`StringName<class_StringName>` anim_name **)**
  133. Notifies when an animation finished playing.
  134. \ **Note:** This signal is not emitted if an animation is looping.
  135. .. rst-class:: classref-item-separator
  136. ----
  137. .. _class_AnimationPlayer_signal_animation_libraries_updated:
  138. .. rst-class:: classref-signal
  139. **animation_libraries_updated** **(** **)**
  140. Notifies when the animation libraries have changed.
  141. .. rst-class:: classref-item-separator
  142. ----
  143. .. _class_AnimationPlayer_signal_animation_list_changed:
  144. .. rst-class:: classref-signal
  145. **animation_list_changed** **(** **)**
  146. Notifies when an animation list is changed.
  147. .. rst-class:: classref-item-separator
  148. ----
  149. .. _class_AnimationPlayer_signal_animation_started:
  150. .. rst-class:: classref-signal
  151. **animation_started** **(** :ref:`StringName<class_StringName>` anim_name **)**
  152. Notifies when an animation starts playing.
  153. .. rst-class:: classref-item-separator
  154. ----
  155. .. _class_AnimationPlayer_signal_caches_cleared:
  156. .. rst-class:: classref-signal
  157. **caches_cleared** **(** **)**
  158. Notifies when the caches have been cleared, either automatically, or manually via :ref:`clear_caches<class_AnimationPlayer_method_clear_caches>`.
  159. .. rst-class:: classref-section-separator
  160. ----
  161. .. rst-class:: classref-descriptions-group
  162. Enumerations
  163. ------------
  164. .. _enum_AnimationPlayer_AnimationProcessCallback:
  165. .. rst-class:: classref-enumeration
  166. enum **AnimationProcessCallback**:
  167. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_PHYSICS:
  168. .. rst-class:: classref-enumeration-constant
  169. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_PHYSICS** = ``0``
  170. Process animation during the physics process. This is especially useful when animating physics bodies.
  171. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_IDLE:
  172. .. rst-class:: classref-enumeration-constant
  173. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_IDLE** = ``1``
  174. Process animation during the idle process.
  175. .. _class_AnimationPlayer_constant_ANIMATION_PROCESS_MANUAL:
  176. .. rst-class:: classref-enumeration-constant
  177. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **ANIMATION_PROCESS_MANUAL** = ``2``
  178. Do not process animation. Use :ref:`advance<class_AnimationPlayer_method_advance>` to process the animation manually.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _enum_AnimationPlayer_AnimationMethodCallMode:
  182. .. rst-class:: classref-enumeration
  183. enum **AnimationMethodCallMode**:
  184. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_DEFERRED:
  185. .. rst-class:: classref-enumeration-constant
  186. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_DEFERRED** = ``0``
  187. 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.
  188. .. _class_AnimationPlayer_constant_ANIMATION_METHOD_CALL_IMMEDIATE:
  189. .. rst-class:: classref-enumeration-constant
  190. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **ANIMATION_METHOD_CALL_IMMEDIATE** = ``1``
  191. Make method calls immediately when reached in the animation.
  192. .. rst-class:: classref-section-separator
  193. ----
  194. .. rst-class:: classref-descriptions-group
  195. Property Descriptions
  196. ---------------------
  197. .. _class_AnimationPlayer_property_assigned_animation:
  198. .. rst-class:: classref-property
  199. :ref:`String<class_String>` **assigned_animation**
  200. .. rst-class:: classref-property-setget
  201. - void **set_assigned_animation** **(** :ref:`String<class_String>` value **)**
  202. - :ref:`String<class_String>` **get_assigned_animation** **(** **)**
  203. If playing, the 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>`.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_AnimationPlayer_property_autoplay:
  207. .. rst-class:: classref-property
  208. :ref:`String<class_String>` **autoplay** = ``""``
  209. .. rst-class:: classref-property-setget
  210. - void **set_autoplay** **(** :ref:`String<class_String>` value **)**
  211. - :ref:`String<class_String>` **get_autoplay** **(** **)**
  212. The key of the animation to play when the scene loads.
  213. .. rst-class:: classref-item-separator
  214. ----
  215. .. _class_AnimationPlayer_property_current_animation:
  216. .. rst-class:: classref-property
  217. :ref:`String<class_String>` **current_animation** = ``""``
  218. .. rst-class:: classref-property-setget
  219. - void **set_current_animation** **(** :ref:`String<class_String>` value **)**
  220. - :ref:`String<class_String>` **get_current_animation** **(** **)**
  221. 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.
  222. \ **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>`.
  223. .. rst-class:: classref-item-separator
  224. ----
  225. .. _class_AnimationPlayer_property_current_animation_length:
  226. .. rst-class:: classref-property
  227. :ref:`float<class_float>` **current_animation_length**
  228. .. rst-class:: classref-property-setget
  229. - :ref:`float<class_float>` **get_current_animation_length** **(** **)**
  230. The length (in seconds) of the currently playing animation.
  231. .. rst-class:: classref-item-separator
  232. ----
  233. .. _class_AnimationPlayer_property_current_animation_position:
  234. .. rst-class:: classref-property
  235. :ref:`float<class_float>` **current_animation_position**
  236. .. rst-class:: classref-property-setget
  237. - :ref:`float<class_float>` **get_current_animation_position** **(** **)**
  238. The position (in seconds) of the currently playing animation.
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_AnimationPlayer_property_method_call_mode:
  242. .. rst-class:: classref-property
  243. :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **method_call_mode** = ``0``
  244. .. rst-class:: classref-property-setget
  245. - void **set_method_call_mode** **(** :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` value **)**
  246. - :ref:`AnimationMethodCallMode<enum_AnimationPlayer_AnimationMethodCallMode>` **get_method_call_mode** **(** **)**
  247. The call mode to use for Call Method tracks.
  248. .. rst-class:: classref-item-separator
  249. ----
  250. .. _class_AnimationPlayer_property_movie_quit_on_finish:
  251. .. rst-class:: classref-property
  252. :ref:`bool<class_bool>` **movie_quit_on_finish** = ``false``
  253. .. rst-class:: classref-property-setget
  254. - void **set_movie_quit_on_finish_enabled** **(** :ref:`bool<class_bool>` value **)**
  255. - :ref:`bool<class_bool>` **is_movie_quit_on_finish_enabled** **(** **)**
  256. 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.
  257. \ **Note:** This obeys the same logic as the :ref:`animation_finished<class_AnimationPlayer_signal_animation_finished>` signal, so it will not quit the engine if the animation is set to be looping.
  258. .. rst-class:: classref-item-separator
  259. ----
  260. .. _class_AnimationPlayer_property_playback_active:
  261. .. rst-class:: classref-property
  262. :ref:`bool<class_bool>` **playback_active**
  263. .. rst-class:: classref-property-setget
  264. - void **set_active** **(** :ref:`bool<class_bool>` value **)**
  265. - :ref:`bool<class_bool>` **is_active** **(** **)**
  266. If ``true``, updates animations in response to process-related notifications.
  267. .. rst-class:: classref-item-separator
  268. ----
  269. .. _class_AnimationPlayer_property_playback_default_blend_time:
  270. .. rst-class:: classref-property
  271. :ref:`float<class_float>` **playback_default_blend_time** = ``0.0``
  272. .. rst-class:: classref-property-setget
  273. - void **set_default_blend_time** **(** :ref:`float<class_float>` value **)**
  274. - :ref:`float<class_float>` **get_default_blend_time** **(** **)**
  275. The default time in which to blend animations. Ranges from 0 to 4096 with 0.01 precision.
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _class_AnimationPlayer_property_playback_process_mode:
  279. .. rst-class:: classref-property
  280. :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **playback_process_mode** = ``1``
  281. .. rst-class:: classref-property-setget
  282. - void **set_process_callback** **(** :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` value **)**
  283. - :ref:`AnimationProcessCallback<enum_AnimationPlayer_AnimationProcessCallback>` **get_process_callback** **(** **)**
  284. The process notification in which to update animations.
  285. .. rst-class:: classref-item-separator
  286. ----
  287. .. _class_AnimationPlayer_property_reset_on_save:
  288. .. rst-class:: classref-property
  289. :ref:`bool<class_bool>` **reset_on_save** = ``true``
  290. .. rst-class:: classref-property-setget
  291. - void **set_reset_on_save_enabled** **(** :ref:`bool<class_bool>` value **)**
  292. - :ref:`bool<class_bool>` **is_reset_on_save_enabled** **(** **)**
  293. This is used by the editor. If set to ``true``, the scene will be saved with the effects of the reset animation (the animation with the key ``"RESET"``) applied as if it had been seeked to time 0, with the editor keeping the values that the scene had before saving.
  294. This makes it more convenient to preview and edit animations in the editor, as changes to the scene will not be saved as long as they are set in the reset animation.
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. _class_AnimationPlayer_property_root_node:
  298. .. rst-class:: classref-property
  299. :ref:`NodePath<class_NodePath>` **root_node** = ``NodePath("..")``
  300. .. rst-class:: classref-property-setget
  301. - void **set_root** **(** :ref:`NodePath<class_NodePath>` value **)**
  302. - :ref:`NodePath<class_NodePath>` **get_root** **(** **)**
  303. The node from which node path references will travel.
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _class_AnimationPlayer_property_speed_scale:
  307. .. rst-class:: classref-property
  308. :ref:`float<class_float>` **speed_scale** = ``1.0``
  309. .. rst-class:: classref-property-setget
  310. - void **set_speed_scale** **(** :ref:`float<class_float>` value **)**
  311. - :ref:`float<class_float>` **get_speed_scale** **(** **)**
  312. 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.
  313. If set to a negative value, the animation is played in reverse. If set to ``0``, the animation will not advance.
  314. .. rst-class:: classref-section-separator
  315. ----
  316. .. rst-class:: classref-descriptions-group
  317. Method Descriptions
  318. -------------------
  319. .. _class_AnimationPlayer_method__post_process_key_value:
  320. .. rst-class:: classref-method
  321. :ref:`Variant<class_Variant>` **_post_process_key_value** **(** :ref:`Animation<class_Animation>` animation, :ref:`int<class_int>` track, :ref:`Variant<class_Variant>` value, :ref:`Object<class_Object>` object, :ref:`int<class_int>` object_idx **)** |virtual| |const|
  322. A virtual function for processing after key getting during playback.
  323. .. rst-class:: classref-item-separator
  324. ----
  325. .. _class_AnimationPlayer_method_add_animation_library:
  326. .. rst-class:: classref-method
  327. :ref:`Error<enum_@GlobalScope_Error>` **add_animation_library** **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationLibrary<class_AnimationLibrary>` library **)**
  328. Adds ``library`` to the animation player, under the key ``name``.
  329. .. rst-class:: classref-item-separator
  330. ----
  331. .. _class_AnimationPlayer_method_advance:
  332. .. rst-class:: classref-method
  333. void **advance** **(** :ref:`float<class_float>` delta **)**
  334. 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.
  335. .. rst-class:: classref-item-separator
  336. ----
  337. .. _class_AnimationPlayer_method_animation_get_next:
  338. .. rst-class:: classref-method
  339. :ref:`StringName<class_StringName>` **animation_get_next** **(** :ref:`StringName<class_StringName>` anim_from **)** |const|
  340. Returns the key of the animation which is queued to play after the ``anim_from`` animation.
  341. .. rst-class:: classref-item-separator
  342. ----
  343. .. _class_AnimationPlayer_method_animation_set_next:
  344. .. rst-class:: classref-method
  345. void **animation_set_next** **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to **)**
  346. Triggers the ``anim_to`` animation when the ``anim_from`` animation completes.
  347. .. rst-class:: classref-item-separator
  348. ----
  349. .. _class_AnimationPlayer_method_clear_caches:
  350. .. rst-class:: classref-method
  351. void **clear_caches** **(** **)**
  352. **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.
  353. .. rst-class:: classref-item-separator
  354. ----
  355. .. _class_AnimationPlayer_method_clear_queue:
  356. .. rst-class:: classref-method
  357. void **clear_queue** **(** **)**
  358. Clears all queued, unplayed animations.
  359. .. rst-class:: classref-item-separator
  360. ----
  361. .. _class_AnimationPlayer_method_find_animation:
  362. .. rst-class:: classref-method
  363. :ref:`StringName<class_StringName>` **find_animation** **(** :ref:`Animation<class_Animation>` animation **)** |const|
  364. Returns the key of ``animation`` or an empty :ref:`StringName<class_StringName>` if not found.
  365. .. rst-class:: classref-item-separator
  366. ----
  367. .. _class_AnimationPlayer_method_find_animation_library:
  368. .. rst-class:: classref-method
  369. :ref:`StringName<class_StringName>` **find_animation_library** **(** :ref:`Animation<class_Animation>` animation **)** |const|
  370. Returns the key for the :ref:`AnimationLibrary<class_AnimationLibrary>` that contains ``animation`` or an empty :ref:`StringName<class_StringName>` if not found.
  371. .. rst-class:: classref-item-separator
  372. ----
  373. .. _class_AnimationPlayer_method_get_animation:
  374. .. rst-class:: classref-method
  375. :ref:`Animation<class_Animation>` **get_animation** **(** :ref:`StringName<class_StringName>` name **)** |const|
  376. Returns the :ref:`Animation<class_Animation>` with the key ``name``. If the animation does not exist, ``null`` is returned and an error is logged.
  377. .. rst-class:: classref-item-separator
  378. ----
  379. .. _class_AnimationPlayer_method_get_animation_library:
  380. .. rst-class:: classref-method
  381. :ref:`AnimationLibrary<class_AnimationLibrary>` **get_animation_library** **(** :ref:`StringName<class_StringName>` name **)** |const|
  382. Returns the first :ref:`AnimationLibrary<class_AnimationLibrary>` with key ``name`` or ``null`` if not found.
  383. .. rst-class:: classref-item-separator
  384. ----
  385. .. _class_AnimationPlayer_method_get_animation_library_list:
  386. .. rst-class:: classref-method
  387. :ref:`StringName[]<class_StringName>` **get_animation_library_list** **(** **)** |const|
  388. Returns the list of stored library keys.
  389. .. rst-class:: classref-item-separator
  390. ----
  391. .. _class_AnimationPlayer_method_get_animation_list:
  392. .. rst-class:: classref-method
  393. :ref:`PackedStringArray<class_PackedStringArray>` **get_animation_list** **(** **)** |const|
  394. Returns the list of stored animation keys.
  395. .. rst-class:: classref-item-separator
  396. ----
  397. .. _class_AnimationPlayer_method_get_blend_time:
  398. .. rst-class:: classref-method
  399. :ref:`float<class_float>` **get_blend_time** **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to **)** |const|
  400. Returns the blend time (in seconds) between two animations, referenced by their keys.
  401. .. rst-class:: classref-item-separator
  402. ----
  403. .. _class_AnimationPlayer_method_get_playing_speed:
  404. .. rst-class:: classref-method
  405. :ref:`float<class_float>` **get_playing_speed** **(** **)** |const|
  406. 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.
  407. Returns a negative value if the current animation is playing backwards.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_AnimationPlayer_method_get_queue:
  411. .. rst-class:: classref-method
  412. :ref:`PackedStringArray<class_PackedStringArray>` **get_queue** **(** **)**
  413. Returns a list of the animation keys that are currently queued to play.
  414. .. rst-class:: classref-item-separator
  415. ----
  416. .. _class_AnimationPlayer_method_has_animation:
  417. .. rst-class:: classref-method
  418. :ref:`bool<class_bool>` **has_animation** **(** :ref:`StringName<class_StringName>` name **)** |const|
  419. Returns ``true`` if the **AnimationPlayer** stores an :ref:`Animation<class_Animation>` with key ``name``.
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_AnimationPlayer_method_has_animation_library:
  423. .. rst-class:: classref-method
  424. :ref:`bool<class_bool>` **has_animation_library** **(** :ref:`StringName<class_StringName>` name **)** |const|
  425. Returns ``true`` if the **AnimationPlayer** stores an :ref:`AnimationLibrary<class_AnimationLibrary>` with key ``name``.
  426. .. rst-class:: classref-item-separator
  427. ----
  428. .. _class_AnimationPlayer_method_is_playing:
  429. .. rst-class:: classref-method
  430. :ref:`bool<class_bool>` **is_playing** **(** **)** |const|
  431. Returns ``true`` if an animation is currently playing (even if :ref:`speed_scale<class_AnimationPlayer_property_speed_scale>` and/or ``custom_speed`` are ``0``).
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _class_AnimationPlayer_method_pause:
  435. .. rst-class:: classref-method
  436. void **pause** **(** **)**
  437. 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.
  438. See also :ref:`stop<class_AnimationPlayer_method_stop>`.
  439. .. rst-class:: classref-item-separator
  440. ----
  441. .. _class_AnimationPlayer_method_play:
  442. .. rst-class:: classref-method
  443. 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 **)**
  444. 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>`).
  445. 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.
  446. \ **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)``.
  447. .. rst-class:: classref-item-separator
  448. ----
  449. .. _class_AnimationPlayer_method_play_backwards:
  450. .. rst-class:: classref-method
  451. void **play_backwards** **(** :ref:`StringName<class_StringName>` name="", :ref:`float<class_float>` custom_blend=-1 **)**
  452. Plays the animation with key ``name`` in reverse.
  453. 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.
  454. .. rst-class:: classref-item-separator
  455. ----
  456. .. _class_AnimationPlayer_method_queue:
  457. .. rst-class:: classref-method
  458. void **queue** **(** :ref:`StringName<class_StringName>` name **)**
  459. Queues an animation for playback once the current one is done.
  460. \ **Note:** If a looped animation is currently playing, the queued animation will never play unless the looped animation is stopped somehow.
  461. .. rst-class:: classref-item-separator
  462. ----
  463. .. _class_AnimationPlayer_method_remove_animation_library:
  464. .. rst-class:: classref-method
  465. void **remove_animation_library** **(** :ref:`StringName<class_StringName>` name **)**
  466. Removes the :ref:`AnimationLibrary<class_AnimationLibrary>` associated with the key ``name``.
  467. .. rst-class:: classref-item-separator
  468. ----
  469. .. _class_AnimationPlayer_method_rename_animation_library:
  470. .. rst-class:: classref-method
  471. void **rename_animation_library** **(** :ref:`StringName<class_StringName>` name, :ref:`StringName<class_StringName>` newname **)**
  472. Moves the :ref:`AnimationLibrary<class_AnimationLibrary>` associated with the key ``name`` to the key ``newname``.
  473. .. rst-class:: classref-item-separator
  474. ----
  475. .. _class_AnimationPlayer_method_seek:
  476. .. rst-class:: classref-method
  477. void **seek** **(** :ref:`float<class_float>` seconds, :ref:`bool<class_bool>` update=false **)**
  478. 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.
  479. \ **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>`.
  480. .. rst-class:: classref-item-separator
  481. ----
  482. .. _class_AnimationPlayer_method_set_blend_time:
  483. .. rst-class:: classref-method
  484. void **set_blend_time** **(** :ref:`StringName<class_StringName>` anim_from, :ref:`StringName<class_StringName>` anim_to, :ref:`float<class_float>` sec **)**
  485. Specifies a blend time (in seconds) between two animations, referenced by their keys.
  486. .. rst-class:: classref-item-separator
  487. ----
  488. .. _class_AnimationPlayer_method_stop:
  489. .. rst-class:: classref-method
  490. void **stop** **(** :ref:`bool<class_bool>` keep_state=false **)**
  491. 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>`.
  492. If ``keep_state`` is ``true``, the animation state is not updated visually.
  493. \ **Note:** The method / audio / animation playback tracks will not be processed by this method.
  494. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  495. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  496. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  497. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  498. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  499. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`