class_animation.rst 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  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/Animation.xml.
  6. .. _class_Animation:
  7. Animation
  8. =========
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Contains data used to animate everything in the engine.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. An Animation resource contains data used to animate everything in the engine. Animations are divided into tracks, and each track must be linked to a node. The state of that node can be changed through time, by adding timed keys (events) to the track.
  15. .. tabs::
  16. .. code-tab:: gdscript
  17. # This creates an animation that makes the node "Enemy" move to the right by
  18. # 100 pixels in 0.5 seconds.
  19. var animation = Animation.new()
  20. var track_index = animation.add_track(Animation.TYPE_VALUE)
  21. animation.track_set_path(track_index, "Enemy:position:x")
  22. animation.track_insert_key(track_index, 0.0, 0)
  23. animation.track_insert_key(track_index, 0.5, 100)
  24. .. code-tab:: csharp
  25. // This creates an animation that makes the node "Enemy" move to the right by
  26. // 100 pixels in 0.5 seconds.
  27. var animation = new Animation();
  28. int trackIndex = animation.AddTrack(Animation.TrackType.Value);
  29. animation.TrackSetPath(trackIndex, "Enemy:position:x");
  30. animation.TrackInsertKey(trackIndex, 0.0f, 0);
  31. animation.TrackInsertKey(trackIndex, 0.5f, 100);
  32. Animations are just data containers, and must be added to nodes such as an :ref:`AnimationPlayer<class_AnimationPlayer>` to be played back. Animation tracks have different types, each with its own set of dedicated methods. Check :ref:`TrackType<enum_Animation_TrackType>` to see available types.
  33. \ **Note:** For 3D position/rotation/scale, using the dedicated :ref:`TYPE_POSITION_3D<class_Animation_constant_TYPE_POSITION_3D>`, :ref:`TYPE_ROTATION_3D<class_Animation_constant_TYPE_ROTATION_3D>` and :ref:`TYPE_SCALE_3D<class_Animation_constant_TYPE_SCALE_3D>` track types instead of :ref:`TYPE_VALUE<class_Animation_constant_TYPE_VALUE>` is recommended for performance reasons.
  34. .. rst-class:: classref-introduction-group
  35. Tutorials
  36. ---------
  37. - :doc:`Animation documentation index <../tutorials/animation/index>`
  38. .. rst-class:: classref-reftable-group
  39. Properties
  40. ----------
  41. .. table::
  42. :widths: auto
  43. +------------------------------------------+------------------------------------------------------+---------+
  44. | :ref:`float<class_float>` | :ref:`length<class_Animation_property_length>` | ``1.0`` |
  45. +------------------------------------------+------------------------------------------------------+---------+
  46. | :ref:`LoopMode<enum_Animation_LoopMode>` | :ref:`loop_mode<class_Animation_property_loop_mode>` | ``0`` |
  47. +------------------------------------------+------------------------------------------------------+---------+
  48. | :ref:`float<class_float>` | :ref:`step<class_Animation_property_step>` | ``0.1`` |
  49. +------------------------------------------+------------------------------------------------------+---------+
  50. .. rst-class:: classref-reftable-group
  51. Methods
  52. -------
  53. .. table::
  54. :widths: auto
  55. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`int<class_int>` | :ref:`add_track<class_Animation_method_add_track>` **(** :ref:`TrackType<enum_Animation_TrackType>` type, :ref:`int<class_int>` at_position=-1 **)** |
  57. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`StringName<class_StringName>` | :ref:`animation_track_get_key_animation<class_Animation_method_animation_track_get_key_animation>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  59. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`int<class_int>` | :ref:`animation_track_insert_key<class_Animation_method_animation_track_insert_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`StringName<class_StringName>` animation **)** |
  61. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`animation_track_set_key_animation<class_Animation_method_animation_track_set_key_animation>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`StringName<class_StringName>` animation **)** |
  63. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`float<class_float>` | :ref:`audio_track_get_key_end_offset<class_Animation_method_audio_track_get_key_end_offset>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  65. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`float<class_float>` | :ref:`audio_track_get_key_start_offset<class_Animation_method_audio_track_get_key_start_offset>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  67. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`Resource<class_Resource>` | :ref:`audio_track_get_key_stream<class_Animation_method_audio_track_get_key_stream>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  69. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`int<class_int>` | :ref:`audio_track_insert_key<class_Animation_method_audio_track_insert_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Resource<class_Resource>` stream, :ref:`float<class_float>` start_offset=0, :ref:`float<class_float>` end_offset=0 **)** |
  71. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`audio_track_set_key_end_offset<class_Animation_method_audio_track_set_key_end_offset>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)** |
  73. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`audio_track_set_key_start_offset<class_Animation_method_audio_track_set_key_start_offset>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)** |
  75. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`audio_track_set_key_stream<class_Animation_method_audio_track_set_key_stream>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`Resource<class_Resource>` stream **)** |
  77. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Vector2<class_Vector2>` | :ref:`bezier_track_get_key_in_handle<class_Animation_method_bezier_track_get_key_in_handle>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  79. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector2<class_Vector2>` | :ref:`bezier_track_get_key_out_handle<class_Animation_method_bezier_track_get_key_out_handle>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  81. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`float<class_float>` | :ref:`bezier_track_get_key_value<class_Animation_method_bezier_track_get_key_value>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  83. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`int<class_int>` | :ref:`bezier_track_insert_key<class_Animation_method_bezier_track_insert_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`float<class_float>` value, :ref:`Vector2<class_Vector2>` in_handle=Vector2(0, 0), :ref:`Vector2<class_Vector2>` out_handle=Vector2(0, 0) **)** |
  85. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`float<class_float>` | :ref:`bezier_track_interpolate<class_Animation_method_bezier_track_interpolate>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time **)** |const| |
  87. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | void | :ref:`bezier_track_set_key_in_handle<class_Animation_method_bezier_track_set_key_in_handle>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`Vector2<class_Vector2>` in_handle, :ref:`float<class_float>` balanced_value_time_ratio=1.0 **)** |
  89. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`bezier_track_set_key_out_handle<class_Animation_method_bezier_track_set_key_out_handle>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`Vector2<class_Vector2>` out_handle, :ref:`float<class_float>` balanced_value_time_ratio=1.0 **)** |
  91. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`bezier_track_set_key_value<class_Animation_method_bezier_track_set_key_value>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` value **)** |
  93. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`int<class_int>` | :ref:`blend_shape_track_insert_key<class_Animation_method_blend_shape_track_insert_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`float<class_float>` amount **)** |
  95. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | void | :ref:`clear<class_Animation_method_clear>` **(** **)** |
  97. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | void | :ref:`compress<class_Animation_method_compress>` **(** :ref:`int<class_int>` page_size=8192, :ref:`int<class_int>` fps=120, :ref:`float<class_float>` split_tolerance=4.0 **)** |
  99. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | void | :ref:`copy_track<class_Animation_method_copy_track>` **(** :ref:`int<class_int>` track_idx, :ref:`Animation<class_Animation>` to_animation **)** |
  101. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`int<class_int>` | :ref:`find_track<class_Animation_method_find_track>` **(** :ref:`NodePath<class_NodePath>` path, :ref:`TrackType<enum_Animation_TrackType>` type **)** |const| |
  103. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`int<class_int>` | :ref:`get_track_count<class_Animation_method_get_track_count>` **(** **)** |const| |
  105. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`StringName<class_StringName>` | :ref:`method_track_get_name<class_Animation_method_method_track_get_name>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  107. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`Array<class_Array>` | :ref:`method_track_get_params<class_Animation_method_method_track_get_params>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  109. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`int<class_int>` | :ref:`position_track_insert_key<class_Animation_method_position_track_insert_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Vector3<class_Vector3>` position **)** |
  111. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`remove_track<class_Animation_method_remove_track>` **(** :ref:`int<class_int>` track_idx **)** |
  113. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`int<class_int>` | :ref:`rotation_track_insert_key<class_Animation_method_rotation_track_insert_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Quaternion<class_Quaternion>` rotation **)** |
  115. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`int<class_int>` | :ref:`scale_track_insert_key<class_Animation_method_scale_track_insert_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Vector3<class_Vector3>` scale **)** |
  117. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`int<class_int>` | :ref:`track_find_key<class_Animation_method_track_find_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`FindMode<enum_Animation_FindMode>` find_mode=0 **)** |const| |
  119. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`bool<class_bool>` | :ref:`track_get_interpolation_loop_wrap<class_Animation_method_track_get_interpolation_loop_wrap>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  121. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`InterpolationType<enum_Animation_InterpolationType>` | :ref:`track_get_interpolation_type<class_Animation_method_track_get_interpolation_type>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  123. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`int<class_int>` | :ref:`track_get_key_count<class_Animation_method_track_get_key_count>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  125. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`float<class_float>` | :ref:`track_get_key_time<class_Animation_method_track_get_key_time>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  127. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`float<class_float>` | :ref:`track_get_key_transition<class_Animation_method_track_get_key_transition>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  129. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`Variant<class_Variant>` | :ref:`track_get_key_value<class_Animation_method_track_get_key_value>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const| |
  131. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :ref:`NodePath<class_NodePath>` | :ref:`track_get_path<class_Animation_method_track_get_path>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  133. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :ref:`TrackType<enum_Animation_TrackType>` | :ref:`track_get_type<class_Animation_method_track_get_type>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  135. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`int<class_int>` | :ref:`track_insert_key<class_Animation_method_track_insert_key>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Variant<class_Variant>` key, :ref:`float<class_float>` transition=1 **)** |
  137. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`bool<class_bool>` | :ref:`track_is_compressed<class_Animation_method_track_is_compressed>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  139. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :ref:`bool<class_bool>` | :ref:`track_is_enabled<class_Animation_method_track_is_enabled>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  141. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | :ref:`bool<class_bool>` | :ref:`track_is_imported<class_Animation_method_track_is_imported>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  143. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | void | :ref:`track_move_down<class_Animation_method_track_move_down>` **(** :ref:`int<class_int>` track_idx **)** |
  145. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | void | :ref:`track_move_to<class_Animation_method_track_move_to>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` to_idx **)** |
  147. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | void | :ref:`track_move_up<class_Animation_method_track_move_up>` **(** :ref:`int<class_int>` track_idx **)** |
  149. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | void | :ref:`track_remove_key<class_Animation_method_track_remove_key>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |
  151. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | void | :ref:`track_remove_key_at_time<class_Animation_method_track_remove_key_at_time>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time **)** |
  153. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | void | :ref:`track_set_enabled<class_Animation_method_track_set_enabled>` **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` enabled **)** |
  155. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. | void | :ref:`track_set_imported<class_Animation_method_track_set_imported>` **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` imported **)** |
  157. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  158. | void | :ref:`track_set_interpolation_loop_wrap<class_Animation_method_track_set_interpolation_loop_wrap>` **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` interpolation **)** |
  159. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  160. | void | :ref:`track_set_interpolation_type<class_Animation_method_track_set_interpolation_type>` **(** :ref:`int<class_int>` track_idx, :ref:`InterpolationType<enum_Animation_InterpolationType>` interpolation **)** |
  161. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  162. | void | :ref:`track_set_key_time<class_Animation_method_track_set_key_time>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` time **)** |
  163. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  164. | void | :ref:`track_set_key_transition<class_Animation_method_track_set_key_transition>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` transition **)** |
  165. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  166. | void | :ref:`track_set_key_value<class_Animation_method_track_set_key_value>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key, :ref:`Variant<class_Variant>` value **)** |
  167. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  168. | void | :ref:`track_set_path<class_Animation_method_track_set_path>` **(** :ref:`int<class_int>` track_idx, :ref:`NodePath<class_NodePath>` path **)** |
  169. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  170. | void | :ref:`track_swap<class_Animation_method_track_swap>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` with_idx **)** |
  171. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  172. | :ref:`UpdateMode<enum_Animation_UpdateMode>` | :ref:`value_track_get_update_mode<class_Animation_method_value_track_get_update_mode>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  173. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  174. | :ref:`Variant<class_Variant>` | :ref:`value_track_interpolate<class_Animation_method_value_track_interpolate>` **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time_sec **)** |const| |
  175. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  176. | void | :ref:`value_track_set_update_mode<class_Animation_method_value_track_set_update_mode>` **(** :ref:`int<class_int>` track_idx, :ref:`UpdateMode<enum_Animation_UpdateMode>` mode **)** |
  177. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  178. .. rst-class:: classref-section-separator
  179. ----
  180. .. rst-class:: classref-descriptions-group
  181. Enumerations
  182. ------------
  183. .. _enum_Animation_TrackType:
  184. .. rst-class:: classref-enumeration
  185. enum **TrackType**:
  186. .. _class_Animation_constant_TYPE_VALUE:
  187. .. rst-class:: classref-enumeration-constant
  188. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_VALUE** = ``0``
  189. Value tracks set values in node properties, but only those which can be interpolated. For 3D position/rotation/scale, using the dedicated :ref:`TYPE_POSITION_3D<class_Animation_constant_TYPE_POSITION_3D>`, :ref:`TYPE_ROTATION_3D<class_Animation_constant_TYPE_ROTATION_3D>` and :ref:`TYPE_SCALE_3D<class_Animation_constant_TYPE_SCALE_3D>` track types instead of :ref:`TYPE_VALUE<class_Animation_constant_TYPE_VALUE>` is recommended for performance reasons.
  190. .. _class_Animation_constant_TYPE_POSITION_3D:
  191. .. rst-class:: classref-enumeration-constant
  192. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_POSITION_3D** = ``1``
  193. 3D position track (values are stored in :ref:`Vector3<class_Vector3>`\ s).
  194. .. _class_Animation_constant_TYPE_ROTATION_3D:
  195. .. rst-class:: classref-enumeration-constant
  196. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_ROTATION_3D** = ``2``
  197. 3D rotation track (values are stored in :ref:`Quaternion<class_Quaternion>`\ s).
  198. .. _class_Animation_constant_TYPE_SCALE_3D:
  199. .. rst-class:: classref-enumeration-constant
  200. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_SCALE_3D** = ``3``
  201. 3D scale track (values are stored in :ref:`Vector3<class_Vector3>`\ s).
  202. .. _class_Animation_constant_TYPE_BLEND_SHAPE:
  203. .. rst-class:: classref-enumeration-constant
  204. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_BLEND_SHAPE** = ``4``
  205. Blend shape track.
  206. .. _class_Animation_constant_TYPE_METHOD:
  207. .. rst-class:: classref-enumeration-constant
  208. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_METHOD** = ``5``
  209. Method tracks call functions with given arguments per key.
  210. .. _class_Animation_constant_TYPE_BEZIER:
  211. .. rst-class:: classref-enumeration-constant
  212. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_BEZIER** = ``6``
  213. Bezier tracks are used to interpolate a value using custom curves. They can also be used to animate sub-properties of vectors and colors (e.g. alpha value of a :ref:`Color<class_Color>`).
  214. .. _class_Animation_constant_TYPE_AUDIO:
  215. .. rst-class:: classref-enumeration-constant
  216. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_AUDIO** = ``7``
  217. Audio tracks are used to play an audio stream with either type of :ref:`AudioStreamPlayer<class_AudioStreamPlayer>`. The stream can be trimmed and previewed in the animation.
  218. .. _class_Animation_constant_TYPE_ANIMATION:
  219. .. rst-class:: classref-enumeration-constant
  220. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_ANIMATION** = ``8``
  221. Animation tracks play animations in other :ref:`AnimationPlayer<class_AnimationPlayer>` nodes.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _enum_Animation_InterpolationType:
  225. .. rst-class:: classref-enumeration
  226. enum **InterpolationType**:
  227. .. _class_Animation_constant_INTERPOLATION_NEAREST:
  228. .. rst-class:: classref-enumeration-constant
  229. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_NEAREST** = ``0``
  230. No interpolation (nearest value).
  231. .. _class_Animation_constant_INTERPOLATION_LINEAR:
  232. .. rst-class:: classref-enumeration-constant
  233. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_LINEAR** = ``1``
  234. Linear interpolation.
  235. .. _class_Animation_constant_INTERPOLATION_CUBIC:
  236. .. rst-class:: classref-enumeration-constant
  237. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_CUBIC** = ``2``
  238. Cubic interpolation. This looks smoother than linear interpolation, but is more expensive to interpolate. Stick to :ref:`INTERPOLATION_LINEAR<class_Animation_constant_INTERPOLATION_LINEAR>` for complex 3D animations imported from external software, even if it requires using a higher animation framerate in return.
  239. .. _class_Animation_constant_INTERPOLATION_LINEAR_ANGLE:
  240. .. rst-class:: classref-enumeration-constant
  241. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_LINEAR_ANGLE** = ``3``
  242. Linear interpolation with shortest path rotation.
  243. \ **Note:** The result value is always normalized and may not match the key value.
  244. .. _class_Animation_constant_INTERPOLATION_CUBIC_ANGLE:
  245. .. rst-class:: classref-enumeration-constant
  246. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_CUBIC_ANGLE** = ``4``
  247. Cubic interpolation with shortest path rotation.
  248. \ **Note:** The result value is always normalized and may not match the key value.
  249. .. rst-class:: classref-item-separator
  250. ----
  251. .. _enum_Animation_UpdateMode:
  252. .. rst-class:: classref-enumeration
  253. enum **UpdateMode**:
  254. .. _class_Animation_constant_UPDATE_CONTINUOUS:
  255. .. rst-class:: classref-enumeration-constant
  256. :ref:`UpdateMode<enum_Animation_UpdateMode>` **UPDATE_CONTINUOUS** = ``0``
  257. Update between keyframes and hold the value.
  258. .. _class_Animation_constant_UPDATE_DISCRETE:
  259. .. rst-class:: classref-enumeration-constant
  260. :ref:`UpdateMode<enum_Animation_UpdateMode>` **UPDATE_DISCRETE** = ``1``
  261. Update at the keyframes.
  262. .. _class_Animation_constant_UPDATE_CAPTURE:
  263. .. rst-class:: classref-enumeration-constant
  264. :ref:`UpdateMode<enum_Animation_UpdateMode>` **UPDATE_CAPTURE** = ``2``
  265. Same as linear interpolation, but also interpolates from the current value (i.e. dynamically at runtime) if the first key isn't at 0 seconds.
  266. .. rst-class:: classref-item-separator
  267. ----
  268. .. _enum_Animation_LoopMode:
  269. .. rst-class:: classref-enumeration
  270. enum **LoopMode**:
  271. .. _class_Animation_constant_LOOP_NONE:
  272. .. rst-class:: classref-enumeration-constant
  273. :ref:`LoopMode<enum_Animation_LoopMode>` **LOOP_NONE** = ``0``
  274. At both ends of the animation, the animation will stop playing.
  275. .. _class_Animation_constant_LOOP_LINEAR:
  276. .. rst-class:: classref-enumeration-constant
  277. :ref:`LoopMode<enum_Animation_LoopMode>` **LOOP_LINEAR** = ``1``
  278. At both ends of the animation, the animation will be repeated without changing the playback direction.
  279. .. _class_Animation_constant_LOOP_PINGPONG:
  280. .. rst-class:: classref-enumeration-constant
  281. :ref:`LoopMode<enum_Animation_LoopMode>` **LOOP_PINGPONG** = ``2``
  282. Repeats playback and reverse playback at both ends of the animation.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _enum_Animation_LoopedFlag:
  286. .. rst-class:: classref-enumeration
  287. enum **LoopedFlag**:
  288. .. _class_Animation_constant_LOOPED_FLAG_NONE:
  289. .. rst-class:: classref-enumeration-constant
  290. :ref:`LoopedFlag<enum_Animation_LoopedFlag>` **LOOPED_FLAG_NONE** = ``0``
  291. This flag indicates that the animation proceeds without any looping.
  292. .. _class_Animation_constant_LOOPED_FLAG_END:
  293. .. rst-class:: classref-enumeration-constant
  294. :ref:`LoopedFlag<enum_Animation_LoopedFlag>` **LOOPED_FLAG_END** = ``1``
  295. This flag indicates that the animation has reached the end of the animation and just after loop processed.
  296. .. _class_Animation_constant_LOOPED_FLAG_START:
  297. .. rst-class:: classref-enumeration-constant
  298. :ref:`LoopedFlag<enum_Animation_LoopedFlag>` **LOOPED_FLAG_START** = ``2``
  299. This flag indicates that the animation has reached the start of the animation and just after loop processed.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _enum_Animation_FindMode:
  303. .. rst-class:: classref-enumeration
  304. enum **FindMode**:
  305. .. _class_Animation_constant_FIND_MODE_NEAREST:
  306. .. rst-class:: classref-enumeration-constant
  307. :ref:`FindMode<enum_Animation_FindMode>` **FIND_MODE_NEAREST** = ``0``
  308. Finds the nearest time key.
  309. .. _class_Animation_constant_FIND_MODE_APPROX:
  310. .. rst-class:: classref-enumeration-constant
  311. :ref:`FindMode<enum_Animation_FindMode>` **FIND_MODE_APPROX** = ``1``
  312. Finds only the key with approximating the time.
  313. .. _class_Animation_constant_FIND_MODE_EXACT:
  314. .. rst-class:: classref-enumeration-constant
  315. :ref:`FindMode<enum_Animation_FindMode>` **FIND_MODE_EXACT** = ``2``
  316. Finds only the key with matching the time.
  317. .. rst-class:: classref-section-separator
  318. ----
  319. .. rst-class:: classref-descriptions-group
  320. Property Descriptions
  321. ---------------------
  322. .. _class_Animation_property_length:
  323. .. rst-class:: classref-property
  324. :ref:`float<class_float>` **length** = ``1.0``
  325. .. rst-class:: classref-property-setget
  326. - void **set_length** **(** :ref:`float<class_float>` value **)**
  327. - :ref:`float<class_float>` **get_length** **(** **)**
  328. The total length of the animation (in seconds).
  329. \ **Note:** Length is not delimited by the last key, as this one may be before or after the end to ensure correct interpolation and looping.
  330. .. rst-class:: classref-item-separator
  331. ----
  332. .. _class_Animation_property_loop_mode:
  333. .. rst-class:: classref-property
  334. :ref:`LoopMode<enum_Animation_LoopMode>` **loop_mode** = ``0``
  335. .. rst-class:: classref-property-setget
  336. - void **set_loop_mode** **(** :ref:`LoopMode<enum_Animation_LoopMode>` value **)**
  337. - :ref:`LoopMode<enum_Animation_LoopMode>` **get_loop_mode** **(** **)**
  338. Determines the behavior of both ends of the animation timeline during animation playback. This is used for correct interpolation of animation cycles, and for hinting the player that it must restart the animation.
  339. .. rst-class:: classref-item-separator
  340. ----
  341. .. _class_Animation_property_step:
  342. .. rst-class:: classref-property
  343. :ref:`float<class_float>` **step** = ``0.1``
  344. .. rst-class:: classref-property-setget
  345. - void **set_step** **(** :ref:`float<class_float>` value **)**
  346. - :ref:`float<class_float>` **get_step** **(** **)**
  347. The animation step value.
  348. .. rst-class:: classref-section-separator
  349. ----
  350. .. rst-class:: classref-descriptions-group
  351. Method Descriptions
  352. -------------------
  353. .. _class_Animation_method_add_track:
  354. .. rst-class:: classref-method
  355. :ref:`int<class_int>` **add_track** **(** :ref:`TrackType<enum_Animation_TrackType>` type, :ref:`int<class_int>` at_position=-1 **)**
  356. Adds a track to the Animation.
  357. .. rst-class:: classref-item-separator
  358. ----
  359. .. _class_Animation_method_animation_track_get_key_animation:
  360. .. rst-class:: classref-method
  361. :ref:`StringName<class_StringName>` **animation_track_get_key_animation** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  362. Returns the animation name at the key identified by ``key_idx``. The ``track_idx`` must be the index of an Animation Track.
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_Animation_method_animation_track_insert_key:
  366. .. rst-class:: classref-method
  367. :ref:`int<class_int>` **animation_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`StringName<class_StringName>` animation **)**
  368. Inserts a key with value ``animation`` at the given ``time`` (in seconds). The ``track_idx`` must be the index of an Animation Track.
  369. .. rst-class:: classref-item-separator
  370. ----
  371. .. _class_Animation_method_animation_track_set_key_animation:
  372. .. rst-class:: classref-method
  373. void **animation_track_set_key_animation** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`StringName<class_StringName>` animation **)**
  374. Sets the key identified by ``key_idx`` to value ``animation``. The ``track_idx`` must be the index of an Animation Track.
  375. .. rst-class:: classref-item-separator
  376. ----
  377. .. _class_Animation_method_audio_track_get_key_end_offset:
  378. .. rst-class:: classref-method
  379. :ref:`float<class_float>` **audio_track_get_key_end_offset** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  380. Returns the end offset of the key identified by ``key_idx``. The ``track_idx`` must be the index of an Audio Track.
  381. End offset is the number of seconds cut off at the ending of the audio stream.
  382. .. rst-class:: classref-item-separator
  383. ----
  384. .. _class_Animation_method_audio_track_get_key_start_offset:
  385. .. rst-class:: classref-method
  386. :ref:`float<class_float>` **audio_track_get_key_start_offset** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  387. Returns the start offset of the key identified by ``key_idx``. The ``track_idx`` must be the index of an Audio Track.
  388. Start offset is the number of seconds cut off at the beginning of the audio stream.
  389. .. rst-class:: classref-item-separator
  390. ----
  391. .. _class_Animation_method_audio_track_get_key_stream:
  392. .. rst-class:: classref-method
  393. :ref:`Resource<class_Resource>` **audio_track_get_key_stream** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  394. Returns the audio stream of the key identified by ``key_idx``. The ``track_idx`` must be the index of an Audio Track.
  395. .. rst-class:: classref-item-separator
  396. ----
  397. .. _class_Animation_method_audio_track_insert_key:
  398. .. rst-class:: classref-method
  399. :ref:`int<class_int>` **audio_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Resource<class_Resource>` stream, :ref:`float<class_float>` start_offset=0, :ref:`float<class_float>` end_offset=0 **)**
  400. Inserts an Audio Track key at the given ``time`` in seconds. The ``track_idx`` must be the index of an Audio Track.
  401. \ ``stream`` is the :ref:`AudioStream<class_AudioStream>` resource to play. ``start_offset`` is the number of seconds cut off at the beginning of the audio stream, while ``end_offset`` is at the ending.
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_Animation_method_audio_track_set_key_end_offset:
  405. .. rst-class:: classref-method
  406. void **audio_track_set_key_end_offset** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)**
  407. Sets the end offset of the key identified by ``key_idx`` to value ``offset``. The ``track_idx`` must be the index of an Audio Track.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_Animation_method_audio_track_set_key_start_offset:
  411. .. rst-class:: classref-method
  412. void **audio_track_set_key_start_offset** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)**
  413. Sets the start offset of the key identified by ``key_idx`` to value ``offset``. The ``track_idx`` must be the index of an Audio Track.
  414. .. rst-class:: classref-item-separator
  415. ----
  416. .. _class_Animation_method_audio_track_set_key_stream:
  417. .. rst-class:: classref-method
  418. void **audio_track_set_key_stream** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`Resource<class_Resource>` stream **)**
  419. Sets the stream of the key identified by ``key_idx`` to value ``stream``. The ``track_idx`` must be the index of an Audio Track.
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_Animation_method_bezier_track_get_key_in_handle:
  423. .. rst-class:: classref-method
  424. :ref:`Vector2<class_Vector2>` **bezier_track_get_key_in_handle** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  425. Returns the in handle of the key identified by ``key_idx``. The ``track_idx`` must be the index of a Bezier Track.
  426. .. rst-class:: classref-item-separator
  427. ----
  428. .. _class_Animation_method_bezier_track_get_key_out_handle:
  429. .. rst-class:: classref-method
  430. :ref:`Vector2<class_Vector2>` **bezier_track_get_key_out_handle** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  431. Returns the out handle of the key identified by ``key_idx``. The ``track_idx`` must be the index of a Bezier Track.
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _class_Animation_method_bezier_track_get_key_value:
  435. .. rst-class:: classref-method
  436. :ref:`float<class_float>` **bezier_track_get_key_value** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  437. Returns the value of the key identified by ``key_idx``. The ``track_idx`` must be the index of a Bezier Track.
  438. .. rst-class:: classref-item-separator
  439. ----
  440. .. _class_Animation_method_bezier_track_insert_key:
  441. .. rst-class:: classref-method
  442. :ref:`int<class_int>` **bezier_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`float<class_float>` value, :ref:`Vector2<class_Vector2>` in_handle=Vector2(0, 0), :ref:`Vector2<class_Vector2>` out_handle=Vector2(0, 0) **)**
  443. Inserts a Bezier Track key at the given ``time`` in seconds. The ``track_idx`` must be the index of a Bezier Track.
  444. \ ``in_handle`` is the left-side weight of the added Bezier curve point, ``out_handle`` is the right-side one, while ``value`` is the actual value at this point.
  445. .. rst-class:: classref-item-separator
  446. ----
  447. .. _class_Animation_method_bezier_track_interpolate:
  448. .. rst-class:: classref-method
  449. :ref:`float<class_float>` **bezier_track_interpolate** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time **)** |const|
  450. Returns the interpolated value at the given ``time`` (in seconds). The ``track_idx`` must be the index of a Bezier Track.
  451. .. rst-class:: classref-item-separator
  452. ----
  453. .. _class_Animation_method_bezier_track_set_key_in_handle:
  454. .. rst-class:: classref-method
  455. void **bezier_track_set_key_in_handle** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`Vector2<class_Vector2>` in_handle, :ref:`float<class_float>` balanced_value_time_ratio=1.0 **)**
  456. Sets the in handle of the key identified by ``key_idx`` to value ``in_handle``. The ``track_idx`` must be the index of a Bezier Track.
  457. .. rst-class:: classref-item-separator
  458. ----
  459. .. _class_Animation_method_bezier_track_set_key_out_handle:
  460. .. rst-class:: classref-method
  461. void **bezier_track_set_key_out_handle** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`Vector2<class_Vector2>` out_handle, :ref:`float<class_float>` balanced_value_time_ratio=1.0 **)**
  462. Sets the out handle of the key identified by ``key_idx`` to value ``out_handle``. The ``track_idx`` must be the index of a Bezier Track.
  463. .. rst-class:: classref-item-separator
  464. ----
  465. .. _class_Animation_method_bezier_track_set_key_value:
  466. .. rst-class:: classref-method
  467. void **bezier_track_set_key_value** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` value **)**
  468. Sets the value of the key identified by ``key_idx`` to the given value. The ``track_idx`` must be the index of a Bezier Track.
  469. .. rst-class:: classref-item-separator
  470. ----
  471. .. _class_Animation_method_blend_shape_track_insert_key:
  472. .. rst-class:: classref-method
  473. :ref:`int<class_int>` **blend_shape_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`float<class_float>` amount **)**
  474. Inserts a key in a given blend shape track. Returns the key index.
  475. .. rst-class:: classref-item-separator
  476. ----
  477. .. _class_Animation_method_clear:
  478. .. rst-class:: classref-method
  479. void **clear** **(** **)**
  480. Clear the animation (clear all tracks and reset all).
  481. .. rst-class:: classref-item-separator
  482. ----
  483. .. _class_Animation_method_compress:
  484. .. rst-class:: classref-method
  485. void **compress** **(** :ref:`int<class_int>` page_size=8192, :ref:`int<class_int>` fps=120, :ref:`float<class_float>` split_tolerance=4.0 **)**
  486. Compress the animation and all its tracks in-place. This will make :ref:`track_is_compressed<class_Animation_method_track_is_compressed>` return ``true`` once called on this **Animation**. Compressed tracks require less memory to be played, and are designed to be used for complex 3D animations (such as cutscenes) imported from external 3D software. Compression is lossy, but the difference is usually not noticeable in real world conditions.
  487. \ **Note:** Compressed tracks have various limitations (such as not being editable from the editor), so only use compressed animations if you actually need them.
  488. .. rst-class:: classref-item-separator
  489. ----
  490. .. _class_Animation_method_copy_track:
  491. .. rst-class:: classref-method
  492. void **copy_track** **(** :ref:`int<class_int>` track_idx, :ref:`Animation<class_Animation>` to_animation **)**
  493. Adds a new track that is a copy of the given track from ``to_animation``.
  494. .. rst-class:: classref-item-separator
  495. ----
  496. .. _class_Animation_method_find_track:
  497. .. rst-class:: classref-method
  498. :ref:`int<class_int>` **find_track** **(** :ref:`NodePath<class_NodePath>` path, :ref:`TrackType<enum_Animation_TrackType>` type **)** |const|
  499. Returns the index of the specified track. If the track is not found, return -1.
  500. .. rst-class:: classref-item-separator
  501. ----
  502. .. _class_Animation_method_get_track_count:
  503. .. rst-class:: classref-method
  504. :ref:`int<class_int>` **get_track_count** **(** **)** |const|
  505. Returns the amount of tracks in the animation.
  506. .. rst-class:: classref-item-separator
  507. ----
  508. .. _class_Animation_method_method_track_get_name:
  509. .. rst-class:: classref-method
  510. :ref:`StringName<class_StringName>` **method_track_get_name** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  511. Returns the method name of a method track.
  512. .. rst-class:: classref-item-separator
  513. ----
  514. .. _class_Animation_method_method_track_get_params:
  515. .. rst-class:: classref-method
  516. :ref:`Array<class_Array>` **method_track_get_params** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  517. Returns the arguments values to be called on a method track for a given key in a given track.
  518. .. rst-class:: classref-item-separator
  519. ----
  520. .. _class_Animation_method_position_track_insert_key:
  521. .. rst-class:: classref-method
  522. :ref:`int<class_int>` **position_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Vector3<class_Vector3>` position **)**
  523. Inserts a key in a given 3D position track. Returns the key index.
  524. .. rst-class:: classref-item-separator
  525. ----
  526. .. _class_Animation_method_remove_track:
  527. .. rst-class:: classref-method
  528. void **remove_track** **(** :ref:`int<class_int>` track_idx **)**
  529. Removes a track by specifying the track index.
  530. .. rst-class:: classref-item-separator
  531. ----
  532. .. _class_Animation_method_rotation_track_insert_key:
  533. .. rst-class:: classref-method
  534. :ref:`int<class_int>` **rotation_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Quaternion<class_Quaternion>` rotation **)**
  535. Inserts a key in a given 3D rotation track. Returns the key index.
  536. .. rst-class:: classref-item-separator
  537. ----
  538. .. _class_Animation_method_scale_track_insert_key:
  539. .. rst-class:: classref-method
  540. :ref:`int<class_int>` **scale_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Vector3<class_Vector3>` scale **)**
  541. Inserts a key in a given 3D scale track. Returns the key index.
  542. .. rst-class:: classref-item-separator
  543. ----
  544. .. _class_Animation_method_track_find_key:
  545. .. rst-class:: classref-method
  546. :ref:`int<class_int>` **track_find_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`FindMode<enum_Animation_FindMode>` find_mode=0 **)** |const|
  547. Finds the key index by time in a given track. Optionally, only find it if the approx/exact time is given.
  548. .. rst-class:: classref-item-separator
  549. ----
  550. .. _class_Animation_method_track_get_interpolation_loop_wrap:
  551. .. rst-class:: classref-method
  552. :ref:`bool<class_bool>` **track_get_interpolation_loop_wrap** **(** :ref:`int<class_int>` track_idx **)** |const|
  553. Returns ``true`` if the track at ``track_idx`` wraps the interpolation loop. New tracks wrap the interpolation loop by default.
  554. .. rst-class:: classref-item-separator
  555. ----
  556. .. _class_Animation_method_track_get_interpolation_type:
  557. .. rst-class:: classref-method
  558. :ref:`InterpolationType<enum_Animation_InterpolationType>` **track_get_interpolation_type** **(** :ref:`int<class_int>` track_idx **)** |const|
  559. Returns the interpolation type of a given track.
  560. .. rst-class:: classref-item-separator
  561. ----
  562. .. _class_Animation_method_track_get_key_count:
  563. .. rst-class:: classref-method
  564. :ref:`int<class_int>` **track_get_key_count** **(** :ref:`int<class_int>` track_idx **)** |const|
  565. Returns the number of keys in a given track.
  566. .. rst-class:: classref-item-separator
  567. ----
  568. .. _class_Animation_method_track_get_key_time:
  569. .. rst-class:: classref-method
  570. :ref:`float<class_float>` **track_get_key_time** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  571. Returns the time at which the key is located.
  572. .. rst-class:: classref-item-separator
  573. ----
  574. .. _class_Animation_method_track_get_key_transition:
  575. .. rst-class:: classref-method
  576. :ref:`float<class_float>` **track_get_key_transition** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  577. Returns the transition curve (easing) for a specific key (see the built-in math function :ref:`@GlobalScope.ease<class_@GlobalScope_method_ease>`).
  578. .. rst-class:: classref-item-separator
  579. ----
  580. .. _class_Animation_method_track_get_key_value:
  581. .. rst-class:: classref-method
  582. :ref:`Variant<class_Variant>` **track_get_key_value** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  583. Returns the value of a given key in a given track.
  584. .. rst-class:: classref-item-separator
  585. ----
  586. .. _class_Animation_method_track_get_path:
  587. .. rst-class:: classref-method
  588. :ref:`NodePath<class_NodePath>` **track_get_path** **(** :ref:`int<class_int>` track_idx **)** |const|
  589. Gets the path of a track. For more information on the path format, see :ref:`track_set_path<class_Animation_method_track_set_path>`.
  590. .. rst-class:: classref-item-separator
  591. ----
  592. .. _class_Animation_method_track_get_type:
  593. .. rst-class:: classref-method
  594. :ref:`TrackType<enum_Animation_TrackType>` **track_get_type** **(** :ref:`int<class_int>` track_idx **)** |const|
  595. Gets the type of a track.
  596. .. rst-class:: classref-item-separator
  597. ----
  598. .. _class_Animation_method_track_insert_key:
  599. .. rst-class:: classref-method
  600. :ref:`int<class_int>` **track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Variant<class_Variant>` key, :ref:`float<class_float>` transition=1 **)**
  601. Inserts a generic key in a given track. Returns the key index.
  602. .. rst-class:: classref-item-separator
  603. ----
  604. .. _class_Animation_method_track_is_compressed:
  605. .. rst-class:: classref-method
  606. :ref:`bool<class_bool>` **track_is_compressed** **(** :ref:`int<class_int>` track_idx **)** |const|
  607. Returns ``true`` if the track is compressed, ``false`` otherwise. See also :ref:`compress<class_Animation_method_compress>`.
  608. .. rst-class:: classref-item-separator
  609. ----
  610. .. _class_Animation_method_track_is_enabled:
  611. .. rst-class:: classref-method
  612. :ref:`bool<class_bool>` **track_is_enabled** **(** :ref:`int<class_int>` track_idx **)** |const|
  613. Returns ``true`` if the track at index ``track_idx`` is enabled.
  614. .. rst-class:: classref-item-separator
  615. ----
  616. .. _class_Animation_method_track_is_imported:
  617. .. rst-class:: classref-method
  618. :ref:`bool<class_bool>` **track_is_imported** **(** :ref:`int<class_int>` track_idx **)** |const|
  619. Returns ``true`` if the given track is imported. Else, return ``false``.
  620. .. rst-class:: classref-item-separator
  621. ----
  622. .. _class_Animation_method_track_move_down:
  623. .. rst-class:: classref-method
  624. void **track_move_down** **(** :ref:`int<class_int>` track_idx **)**
  625. Moves a track down.
  626. .. rst-class:: classref-item-separator
  627. ----
  628. .. _class_Animation_method_track_move_to:
  629. .. rst-class:: classref-method
  630. void **track_move_to** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` to_idx **)**
  631. Changes the index position of track ``track_idx`` to the one defined in ``to_idx``.
  632. .. rst-class:: classref-item-separator
  633. ----
  634. .. _class_Animation_method_track_move_up:
  635. .. rst-class:: classref-method
  636. void **track_move_up** **(** :ref:`int<class_int>` track_idx **)**
  637. Moves a track up.
  638. .. rst-class:: classref-item-separator
  639. ----
  640. .. _class_Animation_method_track_remove_key:
  641. .. rst-class:: classref-method
  642. void **track_remove_key** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)**
  643. Removes a key by index in a given track.
  644. .. rst-class:: classref-item-separator
  645. ----
  646. .. _class_Animation_method_track_remove_key_at_time:
  647. .. rst-class:: classref-method
  648. void **track_remove_key_at_time** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time **)**
  649. Removes a key at ``time`` in a given track.
  650. .. rst-class:: classref-item-separator
  651. ----
  652. .. _class_Animation_method_track_set_enabled:
  653. .. rst-class:: classref-method
  654. void **track_set_enabled** **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` enabled **)**
  655. Enables/disables the given track. Tracks are enabled by default.
  656. .. rst-class:: classref-item-separator
  657. ----
  658. .. _class_Animation_method_track_set_imported:
  659. .. rst-class:: classref-method
  660. void **track_set_imported** **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` imported **)**
  661. Sets the given track as imported or not.
  662. .. rst-class:: classref-item-separator
  663. ----
  664. .. _class_Animation_method_track_set_interpolation_loop_wrap:
  665. .. rst-class:: classref-method
  666. void **track_set_interpolation_loop_wrap** **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` interpolation **)**
  667. If ``true``, the track at ``track_idx`` wraps the interpolation loop.
  668. .. rst-class:: classref-item-separator
  669. ----
  670. .. _class_Animation_method_track_set_interpolation_type:
  671. .. rst-class:: classref-method
  672. void **track_set_interpolation_type** **(** :ref:`int<class_int>` track_idx, :ref:`InterpolationType<enum_Animation_InterpolationType>` interpolation **)**
  673. Sets the interpolation type of a given track.
  674. .. rst-class:: classref-item-separator
  675. ----
  676. .. _class_Animation_method_track_set_key_time:
  677. .. rst-class:: classref-method
  678. void **track_set_key_time** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` time **)**
  679. Sets the time of an existing key.
  680. .. rst-class:: classref-item-separator
  681. ----
  682. .. _class_Animation_method_track_set_key_transition:
  683. .. rst-class:: classref-method
  684. void **track_set_key_transition** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` transition **)**
  685. Sets the transition curve (easing) for a specific key (see the built-in math function :ref:`@GlobalScope.ease<class_@GlobalScope_method_ease>`).
  686. .. rst-class:: classref-item-separator
  687. ----
  688. .. _class_Animation_method_track_set_key_value:
  689. .. rst-class:: classref-method
  690. void **track_set_key_value** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key, :ref:`Variant<class_Variant>` value **)**
  691. Sets the value of an existing key.
  692. .. rst-class:: classref-item-separator
  693. ----
  694. .. _class_Animation_method_track_set_path:
  695. .. rst-class:: classref-method
  696. void **track_set_path** **(** :ref:`int<class_int>` track_idx, :ref:`NodePath<class_NodePath>` path **)**
  697. Sets the path of a track. Paths must be valid scene-tree paths to a node and must be specified starting from the parent node of the node that will reproduce the animation. Tracks that control properties or bones must append their name after the path, separated by ``":"``.
  698. For example, ``"character/skeleton:ankle"`` or ``"character/mesh:transform/local"``.
  699. .. rst-class:: classref-item-separator
  700. ----
  701. .. _class_Animation_method_track_swap:
  702. .. rst-class:: classref-method
  703. void **track_swap** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` with_idx **)**
  704. Swaps the track ``track_idx``'s index position with the track ``with_idx``.
  705. .. rst-class:: classref-item-separator
  706. ----
  707. .. _class_Animation_method_value_track_get_update_mode:
  708. .. rst-class:: classref-method
  709. :ref:`UpdateMode<enum_Animation_UpdateMode>` **value_track_get_update_mode** **(** :ref:`int<class_int>` track_idx **)** |const|
  710. Returns the update mode of a value track.
  711. .. rst-class:: classref-item-separator
  712. ----
  713. .. _class_Animation_method_value_track_interpolate:
  714. .. rst-class:: classref-method
  715. :ref:`Variant<class_Variant>` **value_track_interpolate** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time_sec **)** |const|
  716. Returns the interpolated value at the given time (in seconds). The ``track_idx`` must be the index of a value track.
  717. .. rst-class:: classref-item-separator
  718. ----
  719. .. _class_Animation_method_value_track_set_update_mode:
  720. .. rst-class:: classref-method
  721. void **value_track_set_update_mode** **(** :ref:`int<class_int>` track_idx, :ref:`UpdateMode<enum_Animation_UpdateMode>` mode **)**
  722. Sets the update mode (see :ref:`UpdateMode<enum_Animation_UpdateMode>`) of a value track.
  723. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  724. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  725. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  726. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  727. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  728. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`