class_animation.rst 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Animation:
  4. Animation
  5. =========
  6. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Contains data used to animate everything in the engine.
  11. Member Functions
  12. ----------------
  13. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`int<class_int>` | :ref:`add_track<class_Animation_add_track>` **(** :ref:`int<class_int>` type, :ref:`int<class_int>` at_pos=-1 **)** |
  15. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`clear<class_Animation_clear>` **(** **)** |
  17. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`find_track<class_Animation_find_track>` **(** :ref:`NodePath<class_nodepath>` path **)** const |
  19. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`float<class_float>` | :ref:`get_length<class_Animation_get_length>` **(** **)** const |
  21. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`float<class_float>` | :ref:`get_step<class_Animation_get_step>` **(** **)** const |
  23. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`get_track_count<class_Animation_get_track_count>` **(** **)** const |
  25. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`has_loop<class_Animation_has_loop>` **(** **)** const |
  27. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`IntArray<class_intarray>` | :ref:`method_track_get_key_indices<class_Animation_method_track_get_key_indices>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec, :ref:`float<class_float>` delta **)** const |
  29. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`String<class_string>` | :ref:`method_track_get_name<class_Animation_method_track_get_name>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  31. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Array<class_array>` | :ref:`method_track_get_params<class_Animation_method_track_get_params>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  33. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`remove_track<class_Animation_remove_track>` **(** :ref:`int<class_int>` idx **)** |
  35. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_length<class_Animation_set_length>` **(** :ref:`float<class_float>` time_sec **)** |
  37. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_loop<class_Animation_set_loop>` **(** :ref:`bool<class_bool>` enabled **)** |
  39. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_step<class_Animation_set_step>` **(** :ref:`float<class_float>` size_sec **)** |
  41. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`track_find_key<class_Animation_track_find_key>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`bool<class_bool>` exact=false **)** const |
  43. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`track_get_interpolation_type<class_Animation_track_get_interpolation_type>` **(** :ref:`int<class_int>` idx **)** const |
  45. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`track_get_key_count<class_Animation_track_get_key_count>` **(** :ref:`int<class_int>` idx **)** const |
  47. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`track_get_key_time<class_Animation_track_get_key_time>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  49. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`track_get_key_transition<class_Animation_track_get_key_transition>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  51. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`track_get_key_value<class_Animation_track_get_key_value>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const |
  53. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`NodePath<class_nodepath>` | :ref:`track_get_path<class_Animation_track_get_path>` **(** :ref:`int<class_int>` idx **)** const |
  55. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`int<class_int>` | :ref:`track_get_type<class_Animation_track_get_type>` **(** :ref:`int<class_int>` idx **)** const |
  57. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`track_insert_key<class_Animation_track_insert_key>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`Variant<class_variant>` key, :ref:`float<class_float>` transition=1 **)** |
  59. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`bool<class_bool>` | :ref:`track_is_imported<class_Animation_track_is_imported>` **(** :ref:`int<class_int>` idx **)** const |
  61. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`track_move_down<class_Animation_track_move_down>` **(** :ref:`int<class_int>` idx **)** |
  63. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`track_move_up<class_Animation_track_move_up>` **(** :ref:`int<class_int>` idx **)** |
  65. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`track_remove_key<class_Animation_track_remove_key>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** |
  67. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`track_remove_key_at_pos<class_Animation_track_remove_key_at_pos>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` pos **)** |
  69. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`track_set_imported<class_Animation_track_set_imported>` **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` imported **)** |
  71. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`track_set_interpolation_type<class_Animation_track_set_interpolation_type>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` interpolation **)** |
  73. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`track_set_key_transition<class_Animation_track_set_key_transition>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` transition **)** |
  75. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`track_set_key_value<class_Animation_track_set_key_value>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key, :ref:`Variant<class_variant>` value **)** |
  77. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`track_set_path<class_Animation_track_set_path>` **(** :ref:`int<class_int>` idx, :ref:`NodePath<class_nodepath>` path **)** |
  79. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`int<class_int>` | :ref:`transform_track_insert_key<class_Animation_transform_track_insert_key>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`Vector3<class_vector3>` loc, :ref:`Quat<class_quat>` rot, :ref:`Vector3<class_vector3>` scale **)** |
  81. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`Array<class_array>` | :ref:`transform_track_interpolate<class_Animation_transform_track_interpolate>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec **)** const |
  83. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`IntArray<class_intarray>` | :ref:`value_track_get_key_indices<class_Animation_value_track_get_key_indices>` **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec, :ref:`float<class_float>` delta **)** const |
  85. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`int<class_int>` | :ref:`value_track_get_update_mode<class_Animation_value_track_get_update_mode>` **(** :ref:`int<class_int>` idx **)** const |
  87. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | void | :ref:`value_track_set_update_mode<class_Animation_value_track_set_update_mode>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` mode **)** |
  89. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. Numeric Constants
  91. -----------------
  92. - **TYPE_VALUE** = **0** --- Value tracks set values in node properties, but only those which can be Interpolated.
  93. - **TYPE_TRANSFORM** = **1** --- Transform tracks are used to change node local transforms or skeleton pose bones. Transitions are Interpolated.
  94. - **TYPE_METHOD** = **2** --- Method tracks call functions with given arguments per key.
  95. - **INTERPOLATION_NEAREST** = **0** --- No interpolation (nearest value).
  96. - **INTERPOLATION_LINEAR** = **1** --- Linear interpolation.
  97. - **INTERPOLATION_CUBIC** = **2** --- Cubic interpolation.
  98. - **UPDATE_CONTINUOUS** = **0**
  99. - **UPDATE_DISCRETE** = **1**
  100. - **UPDATE_TRIGGER** = **2**
  101. Description
  102. -----------
  103. 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.
  104. Animations are just data containers, and must be added to odes such as an :ref:`AnimationPlayer<class_animationplayer>` or :ref:`AnimationTreePlayer<class_animationtreeplayer>` to be played back.
  105. Member Function Description
  106. ---------------------------
  107. .. _class_Animation_add_track:
  108. - :ref:`int<class_int>` **add_track** **(** :ref:`int<class_int>` type, :ref:`int<class_int>` at_pos=-1 **)**
  109. Add a track to the Animation. The track type must be specified as any of the values in the TYPE\_\* enumeration.
  110. .. _class_Animation_clear:
  111. - void **clear** **(** **)**
  112. Clear the animation (clear all tracks and reset all).
  113. .. _class_Animation_find_track:
  114. - :ref:`int<class_int>` **find_track** **(** :ref:`NodePath<class_nodepath>` path **)** const
  115. Return the index of the specified track. If the track is not found, return -1.
  116. .. _class_Animation_get_length:
  117. - :ref:`float<class_float>` **get_length** **(** **)** const
  118. Return the total length of the animation (in seconds).
  119. .. _class_Animation_get_step:
  120. - :ref:`float<class_float>` **get_step** **(** **)** const
  121. Get the animation step value.
  122. .. _class_Animation_get_track_count:
  123. - :ref:`int<class_int>` **get_track_count** **(** **)** const
  124. Return the amount of tracks in the animation.
  125. .. _class_Animation_has_loop:
  126. - :ref:`bool<class_bool>` **has_loop** **(** **)** const
  127. Return whether the animation has the loop flag set.
  128. .. _class_Animation_method_track_get_key_indices:
  129. - :ref:`IntArray<class_intarray>` **method_track_get_key_indices** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec, :ref:`float<class_float>` delta **)** const
  130. Return all the key indices of a method track, given a position and delta time.
  131. .. _class_Animation_method_track_get_name:
  132. - :ref:`String<class_string>` **method_track_get_name** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  133. Return the method name of a method track.
  134. .. _class_Animation_method_track_get_params:
  135. - :ref:`Array<class_array>` **method_track_get_params** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  136. Return the arguments values to be called on a method track for a given key in a given track.
  137. .. _class_Animation_remove_track:
  138. - void **remove_track** **(** :ref:`int<class_int>` idx **)**
  139. Remove a track by specifying the track index.
  140. .. _class_Animation_set_length:
  141. - void **set_length** **(** :ref:`float<class_float>` time_sec **)**
  142. Set 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.
  143. .. _class_Animation_set_loop:
  144. - void **set_loop** **(** :ref:`bool<class_bool>` enabled **)**
  145. Set 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.
  146. .. _class_Animation_set_step:
  147. - void **set_step** **(** :ref:`float<class_float>` size_sec **)**
  148. Set the animation step value.
  149. .. _class_Animation_track_find_key:
  150. - :ref:`int<class_int>` **track_find_key** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`bool<class_bool>` exact=false **)** const
  151. Find the key index by time in a given track. Optionally, only find it if the exact time is given.
  152. .. _class_Animation_track_get_interpolation_type:
  153. - :ref:`int<class_int>` **track_get_interpolation_type** **(** :ref:`int<class_int>` idx **)** const
  154. Return the interpolation type of a given track, from the INTERPOLATION\_\* enum.
  155. .. _class_Animation_track_get_key_count:
  156. - :ref:`int<class_int>` **track_get_key_count** **(** :ref:`int<class_int>` idx **)** const
  157. Return the amount of keys in a given track.
  158. .. _class_Animation_track_get_key_time:
  159. - :ref:`float<class_float>` **track_get_key_time** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  160. Return the time at which the key is located.
  161. .. _class_Animation_track_get_key_transition:
  162. - :ref:`float<class_float>` **track_get_key_transition** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  163. Return the transition curve (easing) for a specific key (see built-in math function "ease").
  164. .. _class_Animation_track_get_key_value:
  165. - void **track_get_key_value** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)** const
  166. Return the value of a given key in a given track.
  167. .. _class_Animation_track_get_path:
  168. - :ref:`NodePath<class_nodepath>` **track_get_path** **(** :ref:`int<class_int>` idx **)** const
  169. Get the path of a track. for more information on the path format, see :ref:`track_set_path<class_Animation_track_set_path>`
  170. .. _class_Animation_track_get_type:
  171. - :ref:`int<class_int>` **track_get_type** **(** :ref:`int<class_int>` idx **)** const
  172. Get the type of a track.
  173. .. _class_Animation_track_insert_key:
  174. - 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 **)**
  175. Insert a generic key in a given track.
  176. .. _class_Animation_track_is_imported:
  177. - :ref:`bool<class_bool>` **track_is_imported** **(** :ref:`int<class_int>` idx **)** const
  178. Return true if the given track is imported. Else, return false.
  179. .. _class_Animation_track_move_down:
  180. - void **track_move_down** **(** :ref:`int<class_int>` idx **)**
  181. Move a track down.
  182. .. _class_Animation_track_move_up:
  183. - void **track_move_up** **(** :ref:`int<class_int>` idx **)**
  184. Move a track up.
  185. .. _class_Animation_track_remove_key:
  186. - void **track_remove_key** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx **)**
  187. Remove a key by index in a given track.
  188. .. _class_Animation_track_remove_key_at_pos:
  189. - void **track_remove_key_at_pos** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` pos **)**
  190. Remove a key by position (seconds) in a given track.
  191. .. _class_Animation_track_set_imported:
  192. - void **track_set_imported** **(** :ref:`int<class_int>` idx, :ref:`bool<class_bool>` imported **)**
  193. Set the given track as imported or not.
  194. .. _class_Animation_track_set_interpolation_type:
  195. - void **track_set_interpolation_type** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` interpolation **)**
  196. Set the interpolation type of a given track, from the INTERPOLATION\_\* enum.
  197. .. _class_Animation_track_set_key_transition:
  198. - void **track_set_key_transition** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key_idx, :ref:`float<class_float>` transition **)**
  199. Set the transition curve (easing) for a specific key (see built-in math function "ease").
  200. .. _class_Animation_track_set_key_value:
  201. - void **track_set_key_value** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` key, :ref:`Variant<class_variant>` value **)**
  202. Set the value of an existing key.
  203. .. _class_Animation_track_set_path:
  204. - void **track_set_path** **(** :ref:`int<class_int>` idx, :ref:`NodePath<class_nodepath>` path **)**
  205. 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 ":". Example: "character/skeleton:ankle" or "character/mesh:transform/local"
  206. .. _class_Animation_transform_track_insert_key:
  207. - :ref:`int<class_int>` **transform_track_insert_key** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time, :ref:`Vector3<class_vector3>` loc, :ref:`Quat<class_quat>` rot, :ref:`Vector3<class_vector3>` scale **)**
  208. Insert a transform key for a transform track.
  209. .. _class_Animation_transform_track_interpolate:
  210. - :ref:`Array<class_array>` **transform_track_interpolate** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec **)** const
  211. Return 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>`).
  212. .. _class_Animation_value_track_get_key_indices:
  213. - :ref:`IntArray<class_intarray>` **value_track_get_key_indices** **(** :ref:`int<class_int>` idx, :ref:`float<class_float>` time_sec, :ref:`float<class_float>` delta **)** const
  214. Return all the key indices of a value track, given a position and delta time.
  215. .. _class_Animation_value_track_get_update_mode:
  216. - :ref:`int<class_int>` **value_track_get_update_mode** **(** :ref:`int<class_int>` idx **)** const
  217. .. _class_Animation_value_track_set_update_mode:
  218. - void **value_track_set_update_mode** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` mode **)**