class_animation.rst 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Animation.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Animation:
  6. Animation
  7. =========
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Contains data used to animate everything in the engine.
  13. Properties
  14. ----------
  15. +---------------------------+------------------------------------------------+
  16. | :ref:`float<class_float>` | :ref:`length<class_Animation_property_length>` |
  17. +---------------------------+------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`loop<class_Animation_property_loop>` |
  19. +---------------------------+------------------------------------------------+
  20. | :ref:`float<class_float>` | :ref:`step<class_Animation_property_step>` |
  21. +---------------------------+------------------------------------------------+
  22. Methods
  23. -------
  24. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :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 **)** |
  26. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`String<class_String>` | :ref:`animation_track_get_key_animation<class_Animation_method_animation_track_get_key_animation>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  28. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`animation_track_insert_key<class_Animation_method_animation_track_insert_key>` **(** :ref:`int<class_int>` track, :ref:`float<class_float>` time, :ref:`String<class_String>` animation **)** |
  30. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`animation_track_set_key_animation<class_Animation_method_animation_track_set_key_animation>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`String<class_String>` animation **)** |
  32. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`audio_track_get_key_end_offset<class_Animation_method_audio_track_get_key_end_offset>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  34. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`audio_track_get_key_start_offset<class_Animation_method_audio_track_get_key_start_offset>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  36. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Resource<class_Resource>` | :ref:`audio_track_get_key_stream<class_Animation_method_audio_track_get_key_stream>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  38. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`audio_track_insert_key<class_Animation_method_audio_track_insert_key>` **(** :ref:`int<class_int>` track, :ref:`float<class_float>` time, :ref:`Resource<class_Resource>` stream, :ref:`float<class_float>` start_offset=0, :ref:`float<class_float>` end_offset=0 **)** |
  40. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`audio_track_set_key_end_offset<class_Animation_method_audio_track_set_key_end_offset>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)** |
  42. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`audio_track_set_key_start_offset<class_Animation_method_audio_track_set_key_start_offset>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)** |
  44. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`audio_track_set_key_stream<class_Animation_method_audio_track_set_key_stream>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`Resource<class_Resource>` stream **)** |
  46. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Vector2<class_Vector2>` | :ref:`bezier_track_get_key_in_handle<class_Animation_method_bezier_track_get_key_in_handle>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  48. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Vector2<class_Vector2>` | :ref:`bezier_track_get_key_out_handle<class_Animation_method_bezier_track_get_key_out_handle>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  50. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`float<class_float>` | :ref:`bezier_track_get_key_value<class_Animation_method_bezier_track_get_key_value>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  52. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`bezier_track_insert_key<class_Animation_method_bezier_track_insert_key>` **(** :ref:`int<class_int>` track, :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 ) **)** |
  54. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`float<class_float>` | :ref:`bezier_track_interpolate<class_Animation_method_bezier_track_interpolate>` **(** :ref:`int<class_int>` track, :ref:`float<class_float>` time **)** const |
  56. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`bezier_track_set_key_in_handle<class_Animation_method_bezier_track_set_key_in_handle>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`Vector2<class_Vector2>` in_handle **)** |
  58. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`bezier_track_set_key_out_handle<class_Animation_method_bezier_track_set_key_out_handle>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`Vector2<class_Vector2>` out_handle **)** |
  60. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`bezier_track_set_key_value<class_Animation_method_bezier_track_set_key_value>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` value **)** |
  62. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`clear<class_Animation_method_clear>` **(** **)** |
  64. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`copy_track<class_Animation_method_copy_track>` **(** :ref:`int<class_int>` track, :ref:`Animation<class_Animation>` to_animation **)** |
  66. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`int<class_int>` | :ref:`find_track<class_Animation_method_find_track>` **(** :ref:`NodePath<class_NodePath>` path **)** const |
  68. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`int<class_int>` | :ref:`get_track_count<class_Animation_method_get_track_count>` **(** **)** const |
  70. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`method_track_get_key_indices<class_Animation_method_method_track_get_key_indices>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec, :ref:`float<class_float>` delta **)** const |
  72. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`String<class_String>` | :ref:`method_track_get_name<class_Animation_method_method_track_get_name>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  74. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`Array<class_Array>` | :ref:`method_track_get_params<class_Animation_method_method_track_get_params>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  76. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`remove_track<class_Animation_method_remove_track>` **(** :ref:`int<class_int>` idx **)** |
  78. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`int<class_int>` | :ref:`track_find_key<class_Animation_method_track_find_key>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`bool<class_bool>` exact=false **)** const |
  80. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`bool<class_bool>` | :ref:`track_get_interpolation_loop_wrap<class_Animation_method_track_get_interpolation_loop_wrap>` **(** :ref:`int<class_int>` idx **)** const |
  82. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`InterpolationType<enum_Animation_InterpolationType>` | :ref:`track_get_interpolation_type<class_Animation_method_track_get_interpolation_type>` **(** :ref:`int<class_int>` idx **)** const |
  84. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`int<class_int>` | :ref:`track_get_key_count<class_Animation_method_track_get_key_count>` **(** :ref:`int<class_int>` idx **)** const |
  86. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`float<class_float>` | :ref:`track_get_key_time<class_Animation_method_track_get_key_time>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  88. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`float<class_float>` | :ref:`track_get_key_transition<class_Animation_method_track_get_key_transition>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  90. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`Variant<class_Variant>` | :ref:`track_get_key_value<class_Animation_method_track_get_key_value>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  92. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`NodePath<class_NodePath>` | :ref:`track_get_path<class_Animation_method_track_get_path>` **(** :ref:`int<class_int>` idx **)** const |
  94. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`TrackType<enum_Animation_TrackType>` | :ref:`track_get_type<class_Animation_method_track_get_type>` **(** :ref:`int<class_int>` idx **)** const |
  96. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`track_insert_key<class_Animation_method_track_insert_key>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`Variant<class_Variant>` key, :ref:`float<class_float>` transition=1 **)** |
  98. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`track_is_enabled<class_Animation_method_track_is_enabled>` **(** :ref:`int<class_int>` idx **)** const |
  100. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`bool<class_bool>` | :ref:`track_is_imported<class_Animation_method_track_is_imported>` **(** :ref:`int<class_int>` idx **)** const |
  102. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`track_move_down<class_Animation_method_track_move_down>` **(** :ref:`int<class_int>` idx **)** |
  104. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`track_move_up<class_Animation_method_track_move_up>` **(** :ref:`int<class_int>` idx **)** |
  106. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`track_remove_key<class_Animation_method_track_remove_key>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** |
  108. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`track_remove_key_at_position<class_Animation_method_track_remove_key_at_position>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` position **)** |
  110. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`track_set_enabled<class_Animation_method_track_set_enabled>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enabled **)** |
  112. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`track_set_imported<class_Animation_method_track_set_imported>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` imported **)** |
  114. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`track_set_interpolation_loop_wrap<class_Animation_method_track_set_interpolation_loop_wrap>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` interpolation **)** |
  116. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`track_set_interpolation_type<class_Animation_method_track_set_interpolation_type>` **(** :ref:`int<class_int>` idx, :ref:`InterpolationType<enum_Animation_InterpolationType>` interpolation **)** |
  118. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`track_set_key_transition<class_Animation_method_track_set_key_transition>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` transition **)** |
  120. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`track_set_key_value<class_Animation_method_track_set_key_value>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key, :ref:`Variant<class_Variant>` value **)** |
  122. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | void | :ref:`track_set_path<class_Animation_method_track_set_path>` **(** :ref:`int<class_int>` idx, :ref:`NodePath<class_NodePath>` path **)** |
  124. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`track_swap<class_Animation_method_track_swap>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` with_idx **)** |
  126. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`int<class_int>` | :ref:`transform_track_insert_key<class_Animation_method_transform_track_insert_key>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`Vector3<class_Vector3>` location, :ref:`Quat<class_Quat>` rotation, :ref:`Vector3<class_Vector3>` scale **)** |
  128. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | :ref:`Array<class_Array>` | :ref:`transform_track_interpolate<class_Animation_method_transform_track_interpolate>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec **)** const |
  130. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`value_track_get_key_indices<class_Animation_method_value_track_get_key_indices>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec, :ref:`float<class_float>` delta **)** const |
  132. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`UpdateMode<enum_Animation_UpdateMode>` | :ref:`value_track_get_update_mode<class_Animation_method_value_track_get_update_mode>` **(** :ref:`int<class_int>` idx **)** const |
  134. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | void | :ref:`value_track_set_update_mode<class_Animation_method_value_track_set_update_mode>` **(** :ref:`int<class_int>` idx, :ref:`UpdateMode<enum_Animation_UpdateMode>` mode **)** |
  136. +------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. Signals
  138. -------
  139. .. _class_Animation_signal_tracks_changed:
  140. - **tracks_changed** **(** **)**
  141. Enumerations
  142. ------------
  143. .. _enum_Animation_TrackType:
  144. .. _class_Animation_constant_TYPE_VALUE:
  145. .. _class_Animation_constant_TYPE_TRANSFORM:
  146. .. _class_Animation_constant_TYPE_METHOD:
  147. .. _class_Animation_constant_TYPE_BEZIER:
  148. .. _class_Animation_constant_TYPE_AUDIO:
  149. .. _class_Animation_constant_TYPE_ANIMATION:
  150. enum **TrackType**:
  151. - **TYPE_VALUE** = **0** --- Value tracks set values in node properties, but only those which can be Interpolated.
  152. - **TYPE_TRANSFORM** = **1** --- Transform tracks are used to change node local transforms or skeleton pose bones. Transitions are Interpolated.
  153. - **TYPE_METHOD** = **2** --- Method tracks call functions with given arguments per key.
  154. - **TYPE_BEZIER** = **3**
  155. - **TYPE_AUDIO** = **4**
  156. - **TYPE_ANIMATION** = **5**
  157. .. _enum_Animation_InterpolationType:
  158. .. _class_Animation_constant_INTERPOLATION_NEAREST:
  159. .. _class_Animation_constant_INTERPOLATION_LINEAR:
  160. .. _class_Animation_constant_INTERPOLATION_CUBIC:
  161. enum **InterpolationType**:
  162. - **INTERPOLATION_NEAREST** = **0** --- No interpolation (nearest value).
  163. - **INTERPOLATION_LINEAR** = **1** --- Linear interpolation.
  164. - **INTERPOLATION_CUBIC** = **2** --- Cubic interpolation.
  165. .. _enum_Animation_UpdateMode:
  166. .. _class_Animation_constant_UPDATE_CONTINUOUS:
  167. .. _class_Animation_constant_UPDATE_DISCRETE:
  168. .. _class_Animation_constant_UPDATE_TRIGGER:
  169. .. _class_Animation_constant_UPDATE_CAPTURE:
  170. enum **UpdateMode**:
  171. - **UPDATE_CONTINUOUS** = **0** --- Update between keyframes.
  172. - **UPDATE_DISCRETE** = **1** --- Update at the keyframes and hold the value.
  173. - **UPDATE_TRIGGER** = **2** --- Update at the keyframes.
  174. - **UPDATE_CAPTURE** = **3**
  175. Description
  176. -----------
  177. 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.
  178. ::
  179. # This creates an animation that makes the node "Enemy" move to the right by
  180. # 100 pixels in 1 second.
  181. var animation = Animation.new()
  182. var track_index = animation.add_track(Animation.TYPE_VALUE)
  183. animation.track_set_path(track_index, "Enemy:position.x")
  184. animation.track_insert_key(track_index, 0.0, 0)
  185. animation.track_insert_key(track_index, 0.5, 100)
  186. Animations are just data containers, and must be added to nodes such as an :ref:`AnimationPlayer<class_AnimationPlayer>` or :ref:`AnimationTreePlayer<class_AnimationTreePlayer>` to be played back.
  187. Tutorials
  188. ---------
  189. - :doc:`../tutorials/animation/index`
  190. Property Descriptions
  191. ---------------------
  192. .. _class_Animation_property_length:
  193. - :ref:`float<class_float>` **length**
  194. +----------+-------------------+
  195. | *Setter* | set_length(value) |
  196. +----------+-------------------+
  197. | *Getter* | get_length() |
  198. +----------+-------------------+
  199. The total length of the animation (in seconds). Note that length is not delimited by the last key, as this one may be before or after the end to ensure correct interpolation and looping.
  200. .. _class_Animation_property_loop:
  201. - :ref:`bool<class_bool>` **loop**
  202. +----------+-----------------+
  203. | *Setter* | set_loop(value) |
  204. +----------+-----------------+
  205. | *Getter* | has_loop() |
  206. +----------+-----------------+
  207. A flag indicating that the animation must loop. This is uses for correct interpolation of animation cycles, and for hinting the player that it must restart the animation.
  208. .. _class_Animation_property_step:
  209. - :ref:`float<class_float>` **step**
  210. +----------+-----------------+
  211. | *Setter* | set_step(value) |
  212. +----------+-----------------+
  213. | *Getter* | get_step() |
  214. +----------+-----------------+
  215. The animation step value.
  216. Method Descriptions
  217. -------------------
  218. .. _class_Animation_method_add_track:
  219. - :ref:`int<class_int>` **add_track** **(** :ref:`TrackType<enum_Animation_TrackType>` type, :ref:`int<class_int>` at_position=-1 **)**
  220. Add a track to the Animation. The track type must be specified as any of the values in the TYPE\_\* enumeration.
  221. .. _class_Animation_method_animation_track_get_key_animation:
  222. - :ref:`String<class_String>` **animation_track_get_key_animation** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  223. .. _class_Animation_method_animation_track_insert_key:
  224. - :ref:`int<class_int>` **animation_track_insert_key** **(** :ref:`int<class_int>` track, :ref:`float<class_float>` time, :ref:`String<class_String>` animation **)**
  225. .. _class_Animation_method_animation_track_set_key_animation:
  226. - void **animation_track_set_key_animation** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`String<class_String>` animation **)**
  227. .. _class_Animation_method_audio_track_get_key_end_offset:
  228. - :ref:`float<class_float>` **audio_track_get_key_end_offset** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  229. .. _class_Animation_method_audio_track_get_key_start_offset:
  230. - :ref:`float<class_float>` **audio_track_get_key_start_offset** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  231. .. _class_Animation_method_audio_track_get_key_stream:
  232. - :ref:`Resource<class_Resource>` **audio_track_get_key_stream** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  233. .. _class_Animation_method_audio_track_insert_key:
  234. - :ref:`int<class_int>` **audio_track_insert_key** **(** :ref:`int<class_int>` track, :ref:`float<class_float>` time, :ref:`Resource<class_Resource>` stream, :ref:`float<class_float>` start_offset=0, :ref:`float<class_float>` end_offset=0 **)**
  235. .. _class_Animation_method_audio_track_set_key_end_offset:
  236. - void **audio_track_set_key_end_offset** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)**
  237. .. _class_Animation_method_audio_track_set_key_start_offset:
  238. - void **audio_track_set_key_start_offset** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` offset **)**
  239. .. _class_Animation_method_audio_track_set_key_stream:
  240. - void **audio_track_set_key_stream** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`Resource<class_Resource>` stream **)**
  241. .. _class_Animation_method_bezier_track_get_key_in_handle:
  242. - :ref:`Vector2<class_Vector2>` **bezier_track_get_key_in_handle** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  243. .. _class_Animation_method_bezier_track_get_key_out_handle:
  244. - :ref:`Vector2<class_Vector2>` **bezier_track_get_key_out_handle** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  245. .. _class_Animation_method_bezier_track_get_key_value:
  246. - :ref:`float<class_float>` **bezier_track_get_key_value** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  247. .. _class_Animation_method_bezier_track_insert_key:
  248. - :ref:`int<class_int>` **bezier_track_insert_key** **(** :ref:`int<class_int>` track, :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 ) **)**
  249. .. _class_Animation_method_bezier_track_interpolate:
  250. - :ref:`float<class_float>` **bezier_track_interpolate** **(** :ref:`int<class_int>` track, :ref:`float<class_float>` time **)** const
  251. .. _class_Animation_method_bezier_track_set_key_in_handle:
  252. - void **bezier_track_set_key_in_handle** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`Vector2<class_Vector2>` in_handle **)**
  253. .. _class_Animation_method_bezier_track_set_key_out_handle:
  254. - void **bezier_track_set_key_out_handle** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`Vector2<class_Vector2>` out_handle **)**
  255. .. _class_Animation_method_bezier_track_set_key_value:
  256. - void **bezier_track_set_key_value** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` value **)**
  257. .. _class_Animation_method_clear:
  258. - void **clear** **(** **)**
  259. Clear the animation (clear all tracks and reset all).
  260. .. _class_Animation_method_copy_track:
  261. - void **copy_track** **(** :ref:`int<class_int>` track, :ref:`Animation<class_Animation>` to_animation **)**
  262. Adds a new track that is a copy of the given track from ``to_animation``.
  263. .. _class_Animation_method_find_track:
  264. - :ref:`int<class_int>` **find_track** **(** :ref:`NodePath<class_NodePath>` path **)** const
  265. Returns the index of the specified track. If the track is not found, return -1.
  266. .. _class_Animation_method_get_track_count:
  267. - :ref:`int<class_int>` **get_track_count** **(** **)** const
  268. Returns the amount of tracks in the animation.
  269. .. _class_Animation_method_method_track_get_key_indices:
  270. - :ref:`PoolIntArray<class_PoolIntArray>` **method_track_get_key_indices** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec, :ref:`float<class_float>` delta **)** const
  271. Returns all the key indices of a method track, given a position and delta time.
  272. .. _class_Animation_method_method_track_get_name:
  273. - :ref:`String<class_String>` **method_track_get_name** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  274. Returns the method name of a method track.
  275. .. _class_Animation_method_method_track_get_params:
  276. - :ref:`Array<class_Array>` **method_track_get_params** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  277. Returns the arguments values to be called on a method track for a given key in a given track.
  278. .. _class_Animation_method_remove_track:
  279. - void **remove_track** **(** :ref:`int<class_int>` idx **)**
  280. Remove a track by specifying the track index.
  281. .. _class_Animation_method_track_find_key:
  282. - :ref:`int<class_int>` **track_find_key** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`bool<class_bool>` exact=false **)** const
  283. Find the key index by time in a given track. Optionally, only find it if the exact time is given.
  284. .. _class_Animation_method_track_get_interpolation_loop_wrap:
  285. - :ref:`bool<class_bool>` **track_get_interpolation_loop_wrap** **(** :ref:`int<class_int>` idx **)** const
  286. Returns ``true`` if the track at ``idx`` wraps the interpolation loop. Default value: ``true``.
  287. .. _class_Animation_method_track_get_interpolation_type:
  288. - :ref:`InterpolationType<enum_Animation_InterpolationType>` **track_get_interpolation_type** **(** :ref:`int<class_int>` idx **)** const
  289. Returns the interpolation type of a given track, from the INTERPOLATION\_\* enum.
  290. .. _class_Animation_method_track_get_key_count:
  291. - :ref:`int<class_int>` **track_get_key_count** **(** :ref:`int<class_int>` idx **)** const
  292. Returns the amount of keys in a given track.
  293. .. _class_Animation_method_track_get_key_time:
  294. - :ref:`float<class_float>` **track_get_key_time** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  295. Returns the time at which the key is located.
  296. .. _class_Animation_method_track_get_key_transition:
  297. - :ref:`float<class_float>` **track_get_key_transition** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  298. Returns the transition curve (easing) for a specific key (see built-in math function "ease").
  299. .. _class_Animation_method_track_get_key_value:
  300. - :ref:`Variant<class_Variant>` **track_get_key_value** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  301. Returns the value of a given key in a given track.
  302. .. _class_Animation_method_track_get_path:
  303. - :ref:`NodePath<class_NodePath>` **track_get_path** **(** :ref:`int<class_int>` idx **)** const
  304. Get the path of a track. for more information on the path format, see :ref:`track_set_path<class_Animation_method_track_set_path>`
  305. .. _class_Animation_method_track_get_type:
  306. - :ref:`TrackType<enum_Animation_TrackType>` **track_get_type** **(** :ref:`int<class_int>` idx **)** const
  307. Get the type of a track.
  308. .. _class_Animation_method_track_insert_key:
  309. - void **track_insert_key** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`Variant<class_Variant>` key, :ref:`float<class_float>` transition=1 **)**
  310. Insert a generic key in a given track.
  311. .. _class_Animation_method_track_is_enabled:
  312. - :ref:`bool<class_bool>` **track_is_enabled** **(** :ref:`int<class_int>` idx **)** const
  313. Returns ``true`` if the track at index ``idx`` is enabled.
  314. .. _class_Animation_method_track_is_imported:
  315. - :ref:`bool<class_bool>` **track_is_imported** **(** :ref:`int<class_int>` idx **)** const
  316. Returns ``true`` if the given track is imported. Else, return ``false``.
  317. .. _class_Animation_method_track_move_down:
  318. - void **track_move_down** **(** :ref:`int<class_int>` idx **)**
  319. Move a track down.
  320. .. _class_Animation_method_track_move_up:
  321. - void **track_move_up** **(** :ref:`int<class_int>` idx **)**
  322. Move a track up.
  323. .. _class_Animation_method_track_remove_key:
  324. - void **track_remove_key** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)**
  325. Remove a key by index in a given track.
  326. .. _class_Animation_method_track_remove_key_at_position:
  327. - void **track_remove_key_at_position** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` position **)**
  328. Remove a key by position (seconds) in a given track.
  329. .. _class_Animation_method_track_set_enabled:
  330. - void **track_set_enabled** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` enabled **)**
  331. Enables/disables the given track. Tracks are enabled by default.
  332. .. _class_Animation_method_track_set_imported:
  333. - void **track_set_imported** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` imported **)**
  334. Set the given track as imported or not.
  335. .. _class_Animation_method_track_set_interpolation_loop_wrap:
  336. - void **track_set_interpolation_loop_wrap** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` interpolation **)**
  337. If ``true``, the track at ``idx`` wraps the interpolation loop.
  338. .. _class_Animation_method_track_set_interpolation_type:
  339. - void **track_set_interpolation_type** **(** :ref:`int<class_int>` idx, :ref:`InterpolationType<enum_Animation_InterpolationType>` interpolation **)**
  340. Set the interpolation type of a given track, from the INTERPOLATION\_\* enum.
  341. .. _class_Animation_method_track_set_key_transition:
  342. - void **track_set_key_transition** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` transition **)**
  343. Set the transition curve (easing) for a specific key (see built-in math function "ease").
  344. .. _class_Animation_method_track_set_key_value:
  345. - void **track_set_key_value** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key, :ref:`Variant<class_Variant>` value **)**
  346. Set the value of an existing key.
  347. .. _class_Animation_method_track_set_path:
  348. - void **track_set_path** **(** :ref:`int<class_int>` idx, :ref:`NodePath<class_NodePath>` path **)**
  349. Set 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 ":".
  350. **Example:** "character/skeleton:ankle" or "character/mesh:transform/local".
  351. .. _class_Animation_method_track_swap:
  352. - void **track_swap** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` with_idx **)**
  353. .. _class_Animation_method_transform_track_insert_key:
  354. - :ref:`int<class_int>` **transform_track_insert_key** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`Vector3<class_Vector3>` location, :ref:`Quat<class_Quat>` rotation, :ref:`Vector3<class_Vector3>` scale **)**
  355. Insert a transform key for a transform track.
  356. .. _class_Animation_method_transform_track_interpolate:
  357. - :ref:`Array<class_Array>` **transform_track_interpolate** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec **)** const
  358. Returns the interpolated value of a transform track at a given time (in seconds). An array consisting of 3 elements: position (:ref:`Vector3<class_Vector3>`), rotation (:ref:`Quat<class_Quat>`) and scale (:ref:`Vector3<class_Vector3>`).
  359. .. _class_Animation_method_value_track_get_key_indices:
  360. - :ref:`PoolIntArray<class_PoolIntArray>` **value_track_get_key_indices** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec, :ref:`float<class_float>` delta **)** const
  361. Returns all the key indices of a value track, given a position and delta time.
  362. .. _class_Animation_method_value_track_get_update_mode:
  363. - :ref:`UpdateMode<enum_Animation_UpdateMode>` **value_track_get_update_mode** **(** :ref:`int<class_int>` idx **)** const
  364. Returns the update mode of a value track.
  365. .. _class_Animation_method_value_track_set_update_mode:
  366. - void **value_track_set_update_mode** **(** :ref:`int<class_int>` idx, :ref:`UpdateMode<enum_Animation_UpdateMode>` mode **)**
  367. Set the update mode (UPDATE\_\*) of a value track.