class_animation.rst 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  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/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/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. Holds data that can be used to animate anything in the engine.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This resource holds data that can be used to animate anything 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. | :ref:`bool<class_bool>` | :ref:`audio_track_is_use_blend<class_Animation_method_audio_track_is_use_blend>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  73. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | 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 **)** |
  75. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | 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 **)** |
  77. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | 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 **)** |
  79. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`audio_track_set_use_blend<class_Animation_method_audio_track_set_use_blend>` **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` enable **)** |
  81. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :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| |
  83. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :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| |
  85. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :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| |
  87. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :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) **)** |
  89. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :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| |
  91. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | 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 **)** |
  93. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | 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 **)** |
  95. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | 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 **)** |
  97. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :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 **)** |
  99. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | void | :ref:`clear<class_Animation_method_clear>` **(** **)** |
  101. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | 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 **)** |
  103. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | void | :ref:`copy_track<class_Animation_method_copy_track>` **(** :ref:`int<class_int>` track_idx, :ref:`Animation<class_Animation>` to_animation **)** |
  105. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`int<class_int>` | :ref:`find_track<class_Animation_method_find_track>` **(** :ref:`NodePath<class_NodePath>` path, :ref:`TrackType<enum_Animation_TrackType>` type **)** |const| |
  107. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`int<class_int>` | :ref:`get_track_count<class_Animation_method_get_track_count>` **(** **)** |const| |
  109. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :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| |
  111. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :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| |
  113. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :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 **)** |
  115. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`remove_track<class_Animation_method_remove_track>` **(** :ref:`int<class_int>` track_idx **)** |
  117. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :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 **)** |
  119. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :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 **)** |
  121. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :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| |
  123. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :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| |
  125. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`InterpolationType<enum_Animation_InterpolationType>` | :ref:`track_get_interpolation_type<class_Animation_method_track_get_interpolation_type>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  127. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`int<class_int>` | :ref:`track_get_key_count<class_Animation_method_track_get_key_count>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  129. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :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| |
  131. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :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| |
  133. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :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| |
  135. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`NodePath<class_NodePath>` | :ref:`track_get_path<class_Animation_method_track_get_path>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  137. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`TrackType<enum_Animation_TrackType>` | :ref:`track_get_type<class_Animation_method_track_get_type>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  139. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :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 **)** |
  141. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | :ref:`bool<class_bool>` | :ref:`track_is_compressed<class_Animation_method_track_is_compressed>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  143. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | :ref:`bool<class_bool>` | :ref:`track_is_enabled<class_Animation_method_track_is_enabled>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  145. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | :ref:`bool<class_bool>` | :ref:`track_is_imported<class_Animation_method_track_is_imported>` **(** :ref:`int<class_int>` track_idx **)** |const| |
  147. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | void | :ref:`track_move_down<class_Animation_method_track_move_down>` **(** :ref:`int<class_int>` track_idx **)** |
  149. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | void | :ref:`track_move_to<class_Animation_method_track_move_to>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` to_idx **)** |
  151. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | void | :ref:`track_move_up<class_Animation_method_track_move_up>` **(** :ref:`int<class_int>` track_idx **)** |
  153. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | void | :ref:`track_remove_key<class_Animation_method_track_remove_key>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |
  155. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. | 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 **)** |
  157. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  158. | void | :ref:`track_set_enabled<class_Animation_method_track_set_enabled>` **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` enabled **)** |
  159. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  160. | void | :ref:`track_set_imported<class_Animation_method_track_set_imported>` **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` imported **)** |
  161. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  162. | 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 **)** |
  163. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  164. | 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 **)** |
  165. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  166. | 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 **)** |
  167. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  168. | 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 **)** |
  169. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  170. | 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 **)** |
  171. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  172. | void | :ref:`track_set_path<class_Animation_method_track_set_path>` **(** :ref:`int<class_int>` track_idx, :ref:`NodePath<class_NodePath>` path **)** |
  173. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  174. | void | :ref:`track_swap<class_Animation_method_track_swap>` **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` with_idx **)** |
  175. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  176. | :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| |
  177. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  178. | :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| |
  179. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  180. | 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 **)** |
  181. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  182. .. rst-class:: classref-section-separator
  183. ----
  184. .. rst-class:: classref-descriptions-group
  185. Enumerations
  186. ------------
  187. .. _enum_Animation_TrackType:
  188. .. rst-class:: classref-enumeration
  189. enum **TrackType**:
  190. .. _class_Animation_constant_TYPE_VALUE:
  191. .. rst-class:: classref-enumeration-constant
  192. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_VALUE** = ``0``
  193. 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.
  194. .. _class_Animation_constant_TYPE_POSITION_3D:
  195. .. rst-class:: classref-enumeration-constant
  196. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_POSITION_3D** = ``1``
  197. 3D position track (values are stored in :ref:`Vector3<class_Vector3>`\ s).
  198. .. _class_Animation_constant_TYPE_ROTATION_3D:
  199. .. rst-class:: classref-enumeration-constant
  200. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_ROTATION_3D** = ``2``
  201. 3D rotation track (values are stored in :ref:`Quaternion<class_Quaternion>`\ s).
  202. .. _class_Animation_constant_TYPE_SCALE_3D:
  203. .. rst-class:: classref-enumeration-constant
  204. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_SCALE_3D** = ``3``
  205. 3D scale track (values are stored in :ref:`Vector3<class_Vector3>`\ s).
  206. .. _class_Animation_constant_TYPE_BLEND_SHAPE:
  207. .. rst-class:: classref-enumeration-constant
  208. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_BLEND_SHAPE** = ``4``
  209. Blend shape track.
  210. .. _class_Animation_constant_TYPE_METHOD:
  211. .. rst-class:: classref-enumeration-constant
  212. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_METHOD** = ``5``
  213. Method tracks call functions with given arguments per key.
  214. .. _class_Animation_constant_TYPE_BEZIER:
  215. .. rst-class:: classref-enumeration-constant
  216. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_BEZIER** = ``6``
  217. 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>`).
  218. .. _class_Animation_constant_TYPE_AUDIO:
  219. .. rst-class:: classref-enumeration-constant
  220. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_AUDIO** = ``7``
  221. 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.
  222. .. _class_Animation_constant_TYPE_ANIMATION:
  223. .. rst-class:: classref-enumeration-constant
  224. :ref:`TrackType<enum_Animation_TrackType>` **TYPE_ANIMATION** = ``8``
  225. Animation tracks play animations in other :ref:`AnimationPlayer<class_AnimationPlayer>` nodes.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _enum_Animation_InterpolationType:
  229. .. rst-class:: classref-enumeration
  230. enum **InterpolationType**:
  231. .. _class_Animation_constant_INTERPOLATION_NEAREST:
  232. .. rst-class:: classref-enumeration-constant
  233. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_NEAREST** = ``0``
  234. No interpolation (nearest value).
  235. .. _class_Animation_constant_INTERPOLATION_LINEAR:
  236. .. rst-class:: classref-enumeration-constant
  237. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_LINEAR** = ``1``
  238. Linear interpolation.
  239. .. _class_Animation_constant_INTERPOLATION_CUBIC:
  240. .. rst-class:: classref-enumeration-constant
  241. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_CUBIC** = ``2``
  242. 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.
  243. .. _class_Animation_constant_INTERPOLATION_LINEAR_ANGLE:
  244. .. rst-class:: classref-enumeration-constant
  245. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_LINEAR_ANGLE** = ``3``
  246. Linear interpolation with shortest path rotation.
  247. \ **Note:** The result value is always normalized and may not match the key value.
  248. .. _class_Animation_constant_INTERPOLATION_CUBIC_ANGLE:
  249. .. rst-class:: classref-enumeration-constant
  250. :ref:`InterpolationType<enum_Animation_InterpolationType>` **INTERPOLATION_CUBIC_ANGLE** = ``4``
  251. Cubic interpolation with shortest path rotation.
  252. \ **Note:** The result value is always normalized and may not match the key value.
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _enum_Animation_UpdateMode:
  256. .. rst-class:: classref-enumeration
  257. enum **UpdateMode**:
  258. .. _class_Animation_constant_UPDATE_CONTINUOUS:
  259. .. rst-class:: classref-enumeration-constant
  260. :ref:`UpdateMode<enum_Animation_UpdateMode>` **UPDATE_CONTINUOUS** = ``0``
  261. Update between keyframes and hold the value.
  262. .. _class_Animation_constant_UPDATE_DISCRETE:
  263. .. rst-class:: classref-enumeration-constant
  264. :ref:`UpdateMode<enum_Animation_UpdateMode>` **UPDATE_DISCRETE** = ``1``
  265. Update at the keyframes.
  266. .. _class_Animation_constant_UPDATE_CAPTURE:
  267. .. rst-class:: classref-enumeration-constant
  268. :ref:`UpdateMode<enum_Animation_UpdateMode>` **UPDATE_CAPTURE** = ``2``
  269. 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.
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _enum_Animation_LoopMode:
  273. .. rst-class:: classref-enumeration
  274. enum **LoopMode**:
  275. .. _class_Animation_constant_LOOP_NONE:
  276. .. rst-class:: classref-enumeration-constant
  277. :ref:`LoopMode<enum_Animation_LoopMode>` **LOOP_NONE** = ``0``
  278. At both ends of the animation, the animation will stop playing.
  279. .. _class_Animation_constant_LOOP_LINEAR:
  280. .. rst-class:: classref-enumeration-constant
  281. :ref:`LoopMode<enum_Animation_LoopMode>` **LOOP_LINEAR** = ``1``
  282. At both ends of the animation, the animation will be repeated without changing the playback direction.
  283. .. _class_Animation_constant_LOOP_PINGPONG:
  284. .. rst-class:: classref-enumeration-constant
  285. :ref:`LoopMode<enum_Animation_LoopMode>` **LOOP_PINGPONG** = ``2``
  286. Repeats playback and reverse playback at both ends of the animation.
  287. .. rst-class:: classref-item-separator
  288. ----
  289. .. _enum_Animation_LoopedFlag:
  290. .. rst-class:: classref-enumeration
  291. enum **LoopedFlag**:
  292. .. _class_Animation_constant_LOOPED_FLAG_NONE:
  293. .. rst-class:: classref-enumeration-constant
  294. :ref:`LoopedFlag<enum_Animation_LoopedFlag>` **LOOPED_FLAG_NONE** = ``0``
  295. This flag indicates that the animation proceeds without any looping.
  296. .. _class_Animation_constant_LOOPED_FLAG_END:
  297. .. rst-class:: classref-enumeration-constant
  298. :ref:`LoopedFlag<enum_Animation_LoopedFlag>` **LOOPED_FLAG_END** = ``1``
  299. This flag indicates that the animation has reached the end of the animation and just after loop processed.
  300. .. _class_Animation_constant_LOOPED_FLAG_START:
  301. .. rst-class:: classref-enumeration-constant
  302. :ref:`LoopedFlag<enum_Animation_LoopedFlag>` **LOOPED_FLAG_START** = ``2``
  303. This flag indicates that the animation has reached the start of the animation and just after loop processed.
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _enum_Animation_FindMode:
  307. .. rst-class:: classref-enumeration
  308. enum **FindMode**:
  309. .. _class_Animation_constant_FIND_MODE_NEAREST:
  310. .. rst-class:: classref-enumeration-constant
  311. :ref:`FindMode<enum_Animation_FindMode>` **FIND_MODE_NEAREST** = ``0``
  312. Finds the nearest time key.
  313. .. _class_Animation_constant_FIND_MODE_APPROX:
  314. .. rst-class:: classref-enumeration-constant
  315. :ref:`FindMode<enum_Animation_FindMode>` **FIND_MODE_APPROX** = ``1``
  316. Finds only the key with approximating the time.
  317. .. _class_Animation_constant_FIND_MODE_EXACT:
  318. .. rst-class:: classref-enumeration-constant
  319. :ref:`FindMode<enum_Animation_FindMode>` **FIND_MODE_EXACT** = ``2``
  320. Finds only the key with matching the time.
  321. .. rst-class:: classref-section-separator
  322. ----
  323. .. rst-class:: classref-descriptions-group
  324. Property Descriptions
  325. ---------------------
  326. .. _class_Animation_property_length:
  327. .. rst-class:: classref-property
  328. :ref:`float<class_float>` **length** = ``1.0``
  329. .. rst-class:: classref-property-setget
  330. - void **set_length** **(** :ref:`float<class_float>` value **)**
  331. - :ref:`float<class_float>` **get_length** **(** **)**
  332. The total length of the animation (in seconds).
  333. \ **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.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_Animation_property_loop_mode:
  337. .. rst-class:: classref-property
  338. :ref:`LoopMode<enum_Animation_LoopMode>` **loop_mode** = ``0``
  339. .. rst-class:: classref-property-setget
  340. - void **set_loop_mode** **(** :ref:`LoopMode<enum_Animation_LoopMode>` value **)**
  341. - :ref:`LoopMode<enum_Animation_LoopMode>` **get_loop_mode** **(** **)**
  342. 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.
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_Animation_property_step:
  346. .. rst-class:: classref-property
  347. :ref:`float<class_float>` **step** = ``0.1``
  348. .. rst-class:: classref-property-setget
  349. - void **set_step** **(** :ref:`float<class_float>` value **)**
  350. - :ref:`float<class_float>` **get_step** **(** **)**
  351. The animation step value.
  352. .. rst-class:: classref-section-separator
  353. ----
  354. .. rst-class:: classref-descriptions-group
  355. Method Descriptions
  356. -------------------
  357. .. _class_Animation_method_add_track:
  358. .. rst-class:: classref-method
  359. :ref:`int<class_int>` **add_track** **(** :ref:`TrackType<enum_Animation_TrackType>` type, :ref:`int<class_int>` at_position=-1 **)**
  360. Adds a track to the Animation.
  361. .. rst-class:: classref-item-separator
  362. ----
  363. .. _class_Animation_method_animation_track_get_key_animation:
  364. .. rst-class:: classref-method
  365. :ref:`StringName<class_StringName>` **animation_track_get_key_animation** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  366. Returns the animation name at the key identified by ``key_idx``. The ``track_idx`` must be the index of an Animation Track.
  367. .. rst-class:: classref-item-separator
  368. ----
  369. .. _class_Animation_method_animation_track_insert_key:
  370. .. rst-class:: classref-method
  371. :ref:`int<class_int>` **animation_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`StringName<class_StringName>` animation **)**
  372. Inserts a key with value ``animation`` at the given ``time`` (in seconds). The ``track_idx`` must be the index of an Animation Track.
  373. .. rst-class:: classref-item-separator
  374. ----
  375. .. _class_Animation_method_animation_track_set_key_animation:
  376. .. rst-class:: classref-method
  377. void **animation_track_set_key_animation** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`StringName<class_StringName>` animation **)**
  378. Sets the key identified by ``key_idx`` to value ``animation``. The ``track_idx`` must be the index of an Animation Track.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_Animation_method_audio_track_get_key_end_offset:
  382. .. rst-class:: classref-method
  383. :ref:`float<class_float>` **audio_track_get_key_end_offset** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  384. Returns the end offset of the key identified by ``key_idx``. The ``track_idx`` must be the index of an Audio Track.
  385. End offset is the number of seconds cut off at the ending of the audio stream.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_Animation_method_audio_track_get_key_start_offset:
  389. .. rst-class:: classref-method
  390. :ref:`float<class_float>` **audio_track_get_key_start_offset** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  391. Returns the start offset of the key identified by ``key_idx``. The ``track_idx`` must be the index of an Audio Track.
  392. Start offset is the number of seconds cut off at the beginning of the audio stream.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_Animation_method_audio_track_get_key_stream:
  396. .. rst-class:: classref-method
  397. :ref:`Resource<class_Resource>` **audio_track_get_key_stream** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  398. Returns the audio stream of the key identified by ``key_idx``. The ``track_idx`` must be the index of an Audio Track.
  399. .. rst-class:: classref-item-separator
  400. ----
  401. .. _class_Animation_method_audio_track_insert_key:
  402. .. rst-class:: classref-method
  403. :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 **)**
  404. Inserts an Audio Track key at the given ``time`` in seconds. The ``track_idx`` must be the index of an Audio Track.
  405. \ ``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.
  406. .. rst-class:: classref-item-separator
  407. ----
  408. .. _class_Animation_method_audio_track_is_use_blend:
  409. .. rst-class:: classref-method
  410. :ref:`bool<class_bool>` **audio_track_is_use_blend** **(** :ref:`int<class_int>` track_idx **)** |const|
  411. Returns ``true`` if the track at ``track_idx`` will be blended with other animations.
  412. .. rst-class:: classref-item-separator
  413. ----
  414. .. _class_Animation_method_audio_track_set_key_end_offset:
  415. .. rst-class:: classref-method
  416. void **audio_track_set_key_end_offset** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)**
  417. 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.
  418. .. rst-class:: classref-item-separator
  419. ----
  420. .. _class_Animation_method_audio_track_set_key_start_offset:
  421. .. rst-class:: classref-method
  422. void **audio_track_set_key_start_offset** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)**
  423. 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.
  424. .. rst-class:: classref-item-separator
  425. ----
  426. .. _class_Animation_method_audio_track_set_key_stream:
  427. .. rst-class:: classref-method
  428. void **audio_track_set_key_stream** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`Resource<class_Resource>` stream **)**
  429. Sets the stream of the key identified by ``key_idx`` to value ``stream``. The ``track_idx`` must be the index of an Audio Track.
  430. .. rst-class:: classref-item-separator
  431. ----
  432. .. _class_Animation_method_audio_track_set_use_blend:
  433. .. rst-class:: classref-method
  434. void **audio_track_set_use_blend** **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` enable **)**
  435. Sets whether the track will be blended with other animations. If ``true``, the audio playback volume changes depending on the blend value.
  436. .. rst-class:: classref-item-separator
  437. ----
  438. .. _class_Animation_method_bezier_track_get_key_in_handle:
  439. .. rst-class:: classref-method
  440. :ref:`Vector2<class_Vector2>` **bezier_track_get_key_in_handle** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  441. Returns the in handle of the key identified by ``key_idx``. The ``track_idx`` must be the index of a Bezier Track.
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_Animation_method_bezier_track_get_key_out_handle:
  445. .. rst-class:: classref-method
  446. :ref:`Vector2<class_Vector2>` **bezier_track_get_key_out_handle** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  447. Returns the out handle of the key identified by ``key_idx``. The ``track_idx`` must be the index of a Bezier Track.
  448. .. rst-class:: classref-item-separator
  449. ----
  450. .. _class_Animation_method_bezier_track_get_key_value:
  451. .. rst-class:: classref-method
  452. :ref:`float<class_float>` **bezier_track_get_key_value** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  453. Returns the value of the key identified by ``key_idx``. The ``track_idx`` must be the index of a Bezier Track.
  454. .. rst-class:: classref-item-separator
  455. ----
  456. .. _class_Animation_method_bezier_track_insert_key:
  457. .. rst-class:: classref-method
  458. :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) **)**
  459. Inserts a Bezier Track key at the given ``time`` in seconds. The ``track_idx`` must be the index of a Bezier Track.
  460. \ ``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.
  461. .. rst-class:: classref-item-separator
  462. ----
  463. .. _class_Animation_method_bezier_track_interpolate:
  464. .. rst-class:: classref-method
  465. :ref:`float<class_float>` **bezier_track_interpolate** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time **)** |const|
  466. Returns the interpolated value at the given ``time`` (in seconds). The ``track_idx`` must be the index of a Bezier Track.
  467. .. rst-class:: classref-item-separator
  468. ----
  469. .. _class_Animation_method_bezier_track_set_key_in_handle:
  470. .. rst-class:: classref-method
  471. 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 **)**
  472. 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.
  473. .. rst-class:: classref-item-separator
  474. ----
  475. .. _class_Animation_method_bezier_track_set_key_out_handle:
  476. .. rst-class:: classref-method
  477. 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 **)**
  478. 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.
  479. .. rst-class:: classref-item-separator
  480. ----
  481. .. _class_Animation_method_bezier_track_set_key_value:
  482. .. rst-class:: classref-method
  483. void **bezier_track_set_key_value** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` value **)**
  484. 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.
  485. .. rst-class:: classref-item-separator
  486. ----
  487. .. _class_Animation_method_blend_shape_track_insert_key:
  488. .. rst-class:: classref-method
  489. :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 **)**
  490. Inserts a key in a given blend shape track. Returns the key index.
  491. .. rst-class:: classref-item-separator
  492. ----
  493. .. _class_Animation_method_clear:
  494. .. rst-class:: classref-method
  495. void **clear** **(** **)**
  496. Clear the animation (clear all tracks and reset all).
  497. .. rst-class:: classref-item-separator
  498. ----
  499. .. _class_Animation_method_compress:
  500. .. rst-class:: classref-method
  501. void **compress** **(** :ref:`int<class_int>` page_size=8192, :ref:`int<class_int>` fps=120, :ref:`float<class_float>` split_tolerance=4.0 **)**
  502. 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.
  503. \ **Note:** Compressed tracks have various limitations (such as not being editable from the editor), so only use compressed animations if you actually need them.
  504. .. rst-class:: classref-item-separator
  505. ----
  506. .. _class_Animation_method_copy_track:
  507. .. rst-class:: classref-method
  508. void **copy_track** **(** :ref:`int<class_int>` track_idx, :ref:`Animation<class_Animation>` to_animation **)**
  509. Adds a new track that is a copy of the given track from ``to_animation``.
  510. .. rst-class:: classref-item-separator
  511. ----
  512. .. _class_Animation_method_find_track:
  513. .. rst-class:: classref-method
  514. :ref:`int<class_int>` **find_track** **(** :ref:`NodePath<class_NodePath>` path, :ref:`TrackType<enum_Animation_TrackType>` type **)** |const|
  515. Returns the index of the specified track. If the track is not found, return -1.
  516. .. rst-class:: classref-item-separator
  517. ----
  518. .. _class_Animation_method_get_track_count:
  519. .. rst-class:: classref-method
  520. :ref:`int<class_int>` **get_track_count** **(** **)** |const|
  521. Returns the amount of tracks in the animation.
  522. .. rst-class:: classref-item-separator
  523. ----
  524. .. _class_Animation_method_method_track_get_name:
  525. .. rst-class:: classref-method
  526. :ref:`StringName<class_StringName>` **method_track_get_name** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  527. Returns the method name of a method track.
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_Animation_method_method_track_get_params:
  531. .. rst-class:: classref-method
  532. :ref:`Array<class_Array>` **method_track_get_params** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  533. Returns the arguments values to be called on a method track for a given key in a given track.
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_Animation_method_position_track_insert_key:
  537. .. rst-class:: classref-method
  538. :ref:`int<class_int>` **position_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Vector3<class_Vector3>` position **)**
  539. Inserts a key in a given 3D position track. Returns the key index.
  540. .. rst-class:: classref-item-separator
  541. ----
  542. .. _class_Animation_method_remove_track:
  543. .. rst-class:: classref-method
  544. void **remove_track** **(** :ref:`int<class_int>` track_idx **)**
  545. Removes a track by specifying the track index.
  546. .. rst-class:: classref-item-separator
  547. ----
  548. .. _class_Animation_method_rotation_track_insert_key:
  549. .. rst-class:: classref-method
  550. :ref:`int<class_int>` **rotation_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Quaternion<class_Quaternion>` rotation **)**
  551. Inserts a key in a given 3D rotation track. Returns the key index.
  552. .. rst-class:: classref-item-separator
  553. ----
  554. .. _class_Animation_method_scale_track_insert_key:
  555. .. rst-class:: classref-method
  556. :ref:`int<class_int>` **scale_track_insert_key** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time, :ref:`Vector3<class_Vector3>` scale **)**
  557. Inserts a key in a given 3D scale track. Returns the key index.
  558. .. rst-class:: classref-item-separator
  559. ----
  560. .. _class_Animation_method_track_find_key:
  561. .. rst-class:: classref-method
  562. :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|
  563. Finds the key index by time in a given track. Optionally, only find it if the approx/exact time is given.
  564. .. rst-class:: classref-item-separator
  565. ----
  566. .. _class_Animation_method_track_get_interpolation_loop_wrap:
  567. .. rst-class:: classref-method
  568. :ref:`bool<class_bool>` **track_get_interpolation_loop_wrap** **(** :ref:`int<class_int>` track_idx **)** |const|
  569. Returns ``true`` if the track at ``track_idx`` wraps the interpolation loop. New tracks wrap the interpolation loop by default.
  570. .. rst-class:: classref-item-separator
  571. ----
  572. .. _class_Animation_method_track_get_interpolation_type:
  573. .. rst-class:: classref-method
  574. :ref:`InterpolationType<enum_Animation_InterpolationType>` **track_get_interpolation_type** **(** :ref:`int<class_int>` track_idx **)** |const|
  575. Returns the interpolation type of a given track.
  576. .. rst-class:: classref-item-separator
  577. ----
  578. .. _class_Animation_method_track_get_key_count:
  579. .. rst-class:: classref-method
  580. :ref:`int<class_int>` **track_get_key_count** **(** :ref:`int<class_int>` track_idx **)** |const|
  581. Returns the number of keys in a given track.
  582. .. rst-class:: classref-item-separator
  583. ----
  584. .. _class_Animation_method_track_get_key_time:
  585. .. rst-class:: classref-method
  586. :ref:`float<class_float>` **track_get_key_time** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  587. Returns the time at which the key is located.
  588. .. rst-class:: classref-item-separator
  589. ----
  590. .. _class_Animation_method_track_get_key_transition:
  591. .. rst-class:: classref-method
  592. :ref:`float<class_float>` **track_get_key_transition** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  593. Returns the transition curve (easing) for a specific key (see the built-in math function :ref:`@GlobalScope.ease<class_@GlobalScope_method_ease>`).
  594. .. rst-class:: classref-item-separator
  595. ----
  596. .. _class_Animation_method_track_get_key_value:
  597. .. rst-class:: classref-method
  598. :ref:`Variant<class_Variant>` **track_get_key_value** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)** |const|
  599. Returns the value of a given key in a given track.
  600. .. rst-class:: classref-item-separator
  601. ----
  602. .. _class_Animation_method_track_get_path:
  603. .. rst-class:: classref-method
  604. :ref:`NodePath<class_NodePath>` **track_get_path** **(** :ref:`int<class_int>` track_idx **)** |const|
  605. Gets the path of a track. For more information on the path format, see :ref:`track_set_path<class_Animation_method_track_set_path>`.
  606. .. rst-class:: classref-item-separator
  607. ----
  608. .. _class_Animation_method_track_get_type:
  609. .. rst-class:: classref-method
  610. :ref:`TrackType<enum_Animation_TrackType>` **track_get_type** **(** :ref:`int<class_int>` track_idx **)** |const|
  611. Gets the type of a track.
  612. .. rst-class:: classref-item-separator
  613. ----
  614. .. _class_Animation_method_track_insert_key:
  615. .. rst-class:: classref-method
  616. :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 **)**
  617. Inserts a generic key in a given track. Returns the key index.
  618. .. rst-class:: classref-item-separator
  619. ----
  620. .. _class_Animation_method_track_is_compressed:
  621. .. rst-class:: classref-method
  622. :ref:`bool<class_bool>` **track_is_compressed** **(** :ref:`int<class_int>` track_idx **)** |const|
  623. Returns ``true`` if the track is compressed, ``false`` otherwise. See also :ref:`compress<class_Animation_method_compress>`.
  624. .. rst-class:: classref-item-separator
  625. ----
  626. .. _class_Animation_method_track_is_enabled:
  627. .. rst-class:: classref-method
  628. :ref:`bool<class_bool>` **track_is_enabled** **(** :ref:`int<class_int>` track_idx **)** |const|
  629. Returns ``true`` if the track at index ``track_idx`` is enabled.
  630. .. rst-class:: classref-item-separator
  631. ----
  632. .. _class_Animation_method_track_is_imported:
  633. .. rst-class:: classref-method
  634. :ref:`bool<class_bool>` **track_is_imported** **(** :ref:`int<class_int>` track_idx **)** |const|
  635. Returns ``true`` if the given track is imported. Else, return ``false``.
  636. .. rst-class:: classref-item-separator
  637. ----
  638. .. _class_Animation_method_track_move_down:
  639. .. rst-class:: classref-method
  640. void **track_move_down** **(** :ref:`int<class_int>` track_idx **)**
  641. Moves a track down.
  642. .. rst-class:: classref-item-separator
  643. ----
  644. .. _class_Animation_method_track_move_to:
  645. .. rst-class:: classref-method
  646. void **track_move_to** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` to_idx **)**
  647. Changes the index position of track ``track_idx`` to the one defined in ``to_idx``.
  648. .. rst-class:: classref-item-separator
  649. ----
  650. .. _class_Animation_method_track_move_up:
  651. .. rst-class:: classref-method
  652. void **track_move_up** **(** :ref:`int<class_int>` track_idx **)**
  653. Moves a track up.
  654. .. rst-class:: classref-item-separator
  655. ----
  656. .. _class_Animation_method_track_remove_key:
  657. .. rst-class:: classref-method
  658. void **track_remove_key** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx **)**
  659. Removes a key by index in a given track.
  660. .. rst-class:: classref-item-separator
  661. ----
  662. .. _class_Animation_method_track_remove_key_at_time:
  663. .. rst-class:: classref-method
  664. void **track_remove_key_at_time** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time **)**
  665. Removes a key at ``time`` in a given track.
  666. .. rst-class:: classref-item-separator
  667. ----
  668. .. _class_Animation_method_track_set_enabled:
  669. .. rst-class:: classref-method
  670. void **track_set_enabled** **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` enabled **)**
  671. Enables/disables the given track. Tracks are enabled by default.
  672. .. rst-class:: classref-item-separator
  673. ----
  674. .. _class_Animation_method_track_set_imported:
  675. .. rst-class:: classref-method
  676. void **track_set_imported** **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` imported **)**
  677. Sets the given track as imported or not.
  678. .. rst-class:: classref-item-separator
  679. ----
  680. .. _class_Animation_method_track_set_interpolation_loop_wrap:
  681. .. rst-class:: classref-method
  682. void **track_set_interpolation_loop_wrap** **(** :ref:`int<class_int>` track_idx, :ref:`bool<class_bool>` interpolation **)**
  683. If ``true``, the track at ``track_idx`` wraps the interpolation loop.
  684. .. rst-class:: classref-item-separator
  685. ----
  686. .. _class_Animation_method_track_set_interpolation_type:
  687. .. rst-class:: classref-method
  688. void **track_set_interpolation_type** **(** :ref:`int<class_int>` track_idx, :ref:`InterpolationType<enum_Animation_InterpolationType>` interpolation **)**
  689. Sets the interpolation type of a given track.
  690. .. rst-class:: classref-item-separator
  691. ----
  692. .. _class_Animation_method_track_set_key_time:
  693. .. rst-class:: classref-method
  694. void **track_set_key_time** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` time **)**
  695. Sets the time of an existing key.
  696. .. rst-class:: classref-item-separator
  697. ----
  698. .. _class_Animation_method_track_set_key_transition:
  699. .. rst-class:: classref-method
  700. void **track_set_key_transition** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` transition **)**
  701. Sets the transition curve (easing) for a specific key (see the built-in math function :ref:`@GlobalScope.ease<class_@GlobalScope_method_ease>`).
  702. .. rst-class:: classref-item-separator
  703. ----
  704. .. _class_Animation_method_track_set_key_value:
  705. .. rst-class:: classref-method
  706. void **track_set_key_value** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` key, :ref:`Variant<class_Variant>` value **)**
  707. Sets the value of an existing key.
  708. .. rst-class:: classref-item-separator
  709. ----
  710. .. _class_Animation_method_track_set_path:
  711. .. rst-class:: classref-method
  712. void **track_set_path** **(** :ref:`int<class_int>` track_idx, :ref:`NodePath<class_NodePath>` path **)**
  713. 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 ``":"``.
  714. For example, ``"character/skeleton:ankle"`` or ``"character/mesh:transform/local"``.
  715. .. rst-class:: classref-item-separator
  716. ----
  717. .. _class_Animation_method_track_swap:
  718. .. rst-class:: classref-method
  719. void **track_swap** **(** :ref:`int<class_int>` track_idx, :ref:`int<class_int>` with_idx **)**
  720. Swaps the track ``track_idx``'s index position with the track ``with_idx``.
  721. .. rst-class:: classref-item-separator
  722. ----
  723. .. _class_Animation_method_value_track_get_update_mode:
  724. .. rst-class:: classref-method
  725. :ref:`UpdateMode<enum_Animation_UpdateMode>` **value_track_get_update_mode** **(** :ref:`int<class_int>` track_idx **)** |const|
  726. Returns the update mode of a value track.
  727. .. rst-class:: classref-item-separator
  728. ----
  729. .. _class_Animation_method_value_track_interpolate:
  730. .. rst-class:: classref-method
  731. :ref:`Variant<class_Variant>` **value_track_interpolate** **(** :ref:`int<class_int>` track_idx, :ref:`float<class_float>` time_sec **)** |const|
  732. Returns the interpolated value at the given time (in seconds). The ``track_idx`` must be the index of a value track.
  733. .. rst-class:: classref-item-separator
  734. ----
  735. .. _class_Animation_method_value_track_set_update_mode:
  736. .. rst-class:: classref-method
  737. void **value_track_set_update_mode** **(** :ref:`int<class_int>` track_idx, :ref:`UpdateMode<enum_Animation_UpdateMode>` mode **)**
  738. Sets the update mode (see :ref:`UpdateMode<enum_Animation_UpdateMode>`) of a value track.
  739. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  740. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  741. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  742. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  743. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  744. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`