class_animationnodestatemachine.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/AnimationNodeStateMachine.xml.
  6. .. _class_AnimationNodeStateMachine:
  7. AnimationNodeStateMachine
  8. =========================
  9. **Inherits:** :ref:`AnimationRootNode<class_AnimationRootNode>` **<** :ref:`AnimationNode<class_AnimationNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. State machine for control of animations.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Contains multiple nodes representing animation states, connected in a graph. Node transitions can be configured to happen automatically or via code, using a shortest-path algorithm. Retrieve the :ref:`AnimationNodeStateMachinePlayback<class_AnimationNodeStateMachinePlayback>` object from the :ref:`AnimationTree<class_AnimationTree>` node to control it programmatically.
  15. \ **Example:**\
  16. ::
  17. var state_machine = $AnimationTree.get("parameters/playback")
  18. state_machine.travel("some_state")
  19. .. rst-class:: classref-introduction-group
  20. Tutorials
  21. ---------
  22. - :doc:`../tutorials/animation/animation_tree`
  23. .. rst-class:: classref-reftable-group
  24. Methods
  25. -------
  26. .. table::
  27. :widths: auto
  28. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`add_node<class_AnimationNodeStateMachine_method_add_node>` **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node, :ref:`Vector2<class_Vector2>` position=Vector2( 0, 0 ) **)** |
  30. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`add_transition<class_AnimationNodeStateMachine_method_add_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)** |
  32. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`String<class_String>` | :ref:`get_end_node<class_AnimationNodeStateMachine_method_get_end_node>` **(** **)** |const| |
  34. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Vector2<class_Vector2>` | :ref:`get_graph_offset<class_AnimationNodeStateMachine_method_get_graph_offset>` **(** **)** |const| |
  36. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`AnimationNode<class_AnimationNode>` | :ref:`get_node<class_AnimationNodeStateMachine_method_get_node>` **(** :ref:`String<class_String>` name **)** |const| |
  38. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`String<class_String>` | :ref:`get_node_name<class_AnimationNodeStateMachine_method_get_node_name>` **(** :ref:`AnimationNode<class_AnimationNode>` node **)** |const| |
  40. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Vector2<class_Vector2>` | :ref:`get_node_position<class_AnimationNodeStateMachine_method_get_node_position>` **(** :ref:`String<class_String>` name **)** |const| |
  42. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`String<class_String>` | :ref:`get_start_node<class_AnimationNodeStateMachine_method_get_start_node>` **(** **)** |const| |
  44. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` | :ref:`get_transition<class_AnimationNodeStateMachine_method_get_transition>` **(** :ref:`int<class_int>` idx **)** |const| |
  46. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_transition_count<class_AnimationNodeStateMachine_method_get_transition_count>` **(** **)** |const| |
  48. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`String<class_String>` | :ref:`get_transition_from<class_AnimationNodeStateMachine_method_get_transition_from>` **(** :ref:`int<class_int>` idx **)** |const| |
  50. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`String<class_String>` | :ref:`get_transition_to<class_AnimationNodeStateMachine_method_get_transition_to>` **(** :ref:`int<class_int>` idx **)** |const| |
  52. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`has_node<class_AnimationNodeStateMachine_method_has_node>` **(** :ref:`String<class_String>` name **)** |const| |
  54. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`bool<class_bool>` | :ref:`has_transition<class_AnimationNodeStateMachine_method_has_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |const| |
  56. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`remove_node<class_AnimationNodeStateMachine_method_remove_node>` **(** :ref:`String<class_String>` name **)** |
  58. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`remove_transition<class_AnimationNodeStateMachine_method_remove_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |
  60. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`remove_transition_by_index<class_AnimationNodeStateMachine_method_remove_transition_by_index>` **(** :ref:`int<class_int>` idx **)** |
  62. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`rename_node<class_AnimationNodeStateMachine_method_rename_node>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` new_name **)** |
  64. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`replace_node<class_AnimationNodeStateMachine_method_replace_node>` **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node **)** |
  66. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_end_node<class_AnimationNodeStateMachine_method_set_end_node>` **(** :ref:`String<class_String>` name **)** |
  68. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`set_graph_offset<class_AnimationNodeStateMachine_method_set_graph_offset>` **(** :ref:`Vector2<class_Vector2>` offset **)** |
  70. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`set_node_position<class_AnimationNodeStateMachine_method_set_node_position>` **(** :ref:`String<class_String>` name, :ref:`Vector2<class_Vector2>` position **)** |
  72. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`set_start_node<class_AnimationNodeStateMachine_method_set_start_node>` **(** :ref:`String<class_String>` name **)** |
  74. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. .. rst-class:: classref-section-separator
  76. ----
  77. .. rst-class:: classref-descriptions-group
  78. Method Descriptions
  79. -------------------
  80. .. _class_AnimationNodeStateMachine_method_add_node:
  81. .. rst-class:: classref-method
  82. void **add_node** **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node, :ref:`Vector2<class_Vector2>` position=Vector2( 0, 0 ) **)**
  83. Adds a new node to the graph. The ``position`` is used for display in the editor.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_AnimationNodeStateMachine_method_add_transition:
  87. .. rst-class:: classref-method
  88. void **add_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)**
  89. Adds a transition between the given nodes.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_AnimationNodeStateMachine_method_get_end_node:
  93. .. rst-class:: classref-method
  94. :ref:`String<class_String>` **get_end_node** **(** **)** |const|
  95. Returns the graph's end node.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_AnimationNodeStateMachine_method_get_graph_offset:
  99. .. rst-class:: classref-method
  100. :ref:`Vector2<class_Vector2>` **get_graph_offset** **(** **)** |const|
  101. Returns the draw offset of the graph. Used for display in the editor.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_AnimationNodeStateMachine_method_get_node:
  105. .. rst-class:: classref-method
  106. :ref:`AnimationNode<class_AnimationNode>` **get_node** **(** :ref:`String<class_String>` name **)** |const|
  107. Returns the animation node with the given name.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_AnimationNodeStateMachine_method_get_node_name:
  111. .. rst-class:: classref-method
  112. :ref:`String<class_String>` **get_node_name** **(** :ref:`AnimationNode<class_AnimationNode>` node **)** |const|
  113. Returns the given animation node's name.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _class_AnimationNodeStateMachine_method_get_node_position:
  117. .. rst-class:: classref-method
  118. :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`String<class_String>` name **)** |const|
  119. Returns the given node's coordinates. Used for display in the editor.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_AnimationNodeStateMachine_method_get_start_node:
  123. .. rst-class:: classref-method
  124. :ref:`String<class_String>` **get_start_node** **(** **)** |const|
  125. Returns the graph's end node.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_AnimationNodeStateMachine_method_get_transition:
  129. .. rst-class:: classref-method
  130. :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` **get_transition** **(** :ref:`int<class_int>` idx **)** |const|
  131. Returns the given transition.
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. _class_AnimationNodeStateMachine_method_get_transition_count:
  135. .. rst-class:: classref-method
  136. :ref:`int<class_int>` **get_transition_count** **(** **)** |const|
  137. Returns the number of connections in the graph.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_AnimationNodeStateMachine_method_get_transition_from:
  141. .. rst-class:: classref-method
  142. :ref:`String<class_String>` **get_transition_from** **(** :ref:`int<class_int>` idx **)** |const|
  143. Returns the given transition's start node.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_AnimationNodeStateMachine_method_get_transition_to:
  147. .. rst-class:: classref-method
  148. :ref:`String<class_String>` **get_transition_to** **(** :ref:`int<class_int>` idx **)** |const|
  149. Returns the given transition's end node.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_AnimationNodeStateMachine_method_has_node:
  153. .. rst-class:: classref-method
  154. :ref:`bool<class_bool>` **has_node** **(** :ref:`String<class_String>` name **)** |const|
  155. Returns ``true`` if the graph contains the given node.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_AnimationNodeStateMachine_method_has_transition:
  159. .. rst-class:: classref-method
  160. :ref:`bool<class_bool>` **has_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |const|
  161. Returns ``true`` if there is a transition between the given nodes.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_AnimationNodeStateMachine_method_remove_node:
  165. .. rst-class:: classref-method
  166. void **remove_node** **(** :ref:`String<class_String>` name **)**
  167. Deletes the given node from the graph.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_AnimationNodeStateMachine_method_remove_transition:
  171. .. rst-class:: classref-method
  172. void **remove_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)**
  173. Deletes the transition between the two specified nodes.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_AnimationNodeStateMachine_method_remove_transition_by_index:
  177. .. rst-class:: classref-method
  178. void **remove_transition_by_index** **(** :ref:`int<class_int>` idx **)**
  179. Deletes the given transition by index.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_AnimationNodeStateMachine_method_rename_node:
  183. .. rst-class:: classref-method
  184. void **rename_node** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` new_name **)**
  185. Renames the given node.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_AnimationNodeStateMachine_method_replace_node:
  189. .. rst-class:: classref-method
  190. void **replace_node** **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node **)**
  191. Replaces the node and keeps its transitions unchanged.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_AnimationNodeStateMachine_method_set_end_node:
  195. .. rst-class:: classref-method
  196. void **set_end_node** **(** :ref:`String<class_String>` name **)**
  197. Sets the given node as the graph end point.
  198. .. rst-class:: classref-item-separator
  199. ----
  200. .. _class_AnimationNodeStateMachine_method_set_graph_offset:
  201. .. rst-class:: classref-method
  202. void **set_graph_offset** **(** :ref:`Vector2<class_Vector2>` offset **)**
  203. Sets the draw offset of the graph. Used for display in the editor.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_AnimationNodeStateMachine_method_set_node_position:
  207. .. rst-class:: classref-method
  208. void **set_node_position** **(** :ref:`String<class_String>` name, :ref:`Vector2<class_Vector2>` position **)**
  209. Sets the node's coordinates. Used for display in the editor.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_AnimationNodeStateMachine_method_set_start_node:
  213. .. rst-class:: classref-method
  214. void **set_start_node** **(** :ref:`String<class_String>` name **)**
  215. Sets the given node as the graph start point.
  216. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  217. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  218. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  219. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`