class_animationplayer.rst 45 KB

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