class_animationnodestatemachine.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/AnimationNodeStateMachine.xml.
  6. .. _class_AnimationNodeStateMachine:
  7. AnimationNodeStateMachine
  8. =========================
  9. **Inherits:** :ref:`AnimationRootNode<class_AnimationRootNode>` **<** :ref:`AnimationNode<class_AnimationNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A state machine with multiple :ref:`AnimationRootNode<class_AnimationRootNode>`\ s, used by :ref:`AnimationTree<class_AnimationTree>`.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Contains multiple :ref:`AnimationRootNode<class_AnimationRootNode>`\ s 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. .. tabs::
  17. .. code-tab:: gdscript
  18. var state_machine = $AnimationTree.get("parameters/playback")
  19. state_machine.travel("some_state")
  20. .. code-tab:: csharp
  21. var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback;
  22. stateMachine.Travel("some_state");
  23. .. rst-class:: classref-introduction-group
  24. Tutorials
  25. ---------
  26. - :doc:`Using AnimationTree <../tutorials/animation/animation_tree>`
  27. .. rst-class:: classref-reftable-group
  28. Properties
  29. ----------
  30. .. table::
  31. :widths: auto
  32. +-------------------------+----------------------------------------------------------------------------------------------------+-----------+
  33. | :ref:`bool<class_bool>` | :ref:`allow_transition_to_self<class_AnimationNodeStateMachine_property_allow_transition_to_self>` | ``false`` |
  34. +-------------------------+----------------------------------------------------------------------------------------------------+-----------+
  35. .. rst-class:: classref-reftable-group
  36. Methods
  37. -------
  38. .. table::
  39. :widths: auto
  40. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`add_node<class_AnimationNodeStateMachine_method_add_node>` **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationNode<class_AnimationNode>` node, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)** |
  42. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`add_transition<class_AnimationNodeStateMachine_method_add_transition>` **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)** |
  44. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Vector2<class_Vector2>` | :ref:`get_graph_offset<class_AnimationNodeStateMachine_method_get_graph_offset>` **(** **)** |const| |
  46. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`AnimationNode<class_AnimationNode>` | :ref:`get_node<class_AnimationNodeStateMachine_method_get_node>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  48. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`StringName<class_StringName>` | :ref:`get_node_name<class_AnimationNodeStateMachine_method_get_node_name>` **(** :ref:`AnimationNode<class_AnimationNode>` node **)** |const| |
  50. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector2<class_Vector2>` | :ref:`get_node_position<class_AnimationNodeStateMachine_method_get_node_position>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  52. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` | :ref:`get_transition<class_AnimationNodeStateMachine_method_get_transition>` **(** :ref:`int<class_int>` idx **)** |const| |
  54. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`get_transition_count<class_AnimationNodeStateMachine_method_get_transition_count>` **(** **)** |const| |
  56. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`StringName<class_StringName>` | :ref:`get_transition_from<class_AnimationNodeStateMachine_method_get_transition_from>` **(** :ref:`int<class_int>` idx **)** |const| |
  58. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`StringName<class_StringName>` | :ref:`get_transition_to<class_AnimationNodeStateMachine_method_get_transition_to>` **(** :ref:`int<class_int>` idx **)** |const| |
  60. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`has_node<class_AnimationNodeStateMachine_method_has_node>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  62. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`bool<class_bool>` | :ref:`has_transition<class_AnimationNodeStateMachine_method_has_transition>` **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to **)** |const| |
  64. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`remove_node<class_AnimationNodeStateMachine_method_remove_node>` **(** :ref:`StringName<class_StringName>` name **)** |
  66. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`remove_transition<class_AnimationNodeStateMachine_method_remove_transition>` **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to **)** |
  68. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`remove_transition_by_index<class_AnimationNodeStateMachine_method_remove_transition_by_index>` **(** :ref:`int<class_int>` idx **)** |
  70. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`rename_node<class_AnimationNodeStateMachine_method_rename_node>` **(** :ref:`StringName<class_StringName>` name, :ref:`StringName<class_StringName>` new_name **)** |
  72. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`replace_node<class_AnimationNodeStateMachine_method_replace_node>` **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationNode<class_AnimationNode>` node **)** |
  74. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`set_graph_offset<class_AnimationNodeStateMachine_method_set_graph_offset>` **(** :ref:`Vector2<class_Vector2>` offset **)** |
  76. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`set_node_position<class_AnimationNodeStateMachine_method_set_node_position>` **(** :ref:`StringName<class_StringName>` name, :ref:`Vector2<class_Vector2>` position **)** |
  78. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. .. rst-class:: classref-section-separator
  80. ----
  81. .. rst-class:: classref-descriptions-group
  82. Property Descriptions
  83. ---------------------
  84. .. _class_AnimationNodeStateMachine_property_allow_transition_to_self:
  85. .. rst-class:: classref-property
  86. :ref:`bool<class_bool>` **allow_transition_to_self** = ``false``
  87. .. rst-class:: classref-property-setget
  88. - void **set_allow_transition_to_self** **(** :ref:`bool<class_bool>` value **)**
  89. - :ref:`bool<class_bool>` **is_allow_transition_to_self** **(** **)**
  90. If ``true``, allows teleport to the self state with :ref:`AnimationNodeStateMachinePlayback.travel<class_AnimationNodeStateMachinePlayback_method_travel>`. When the reset option is enabled in :ref:`AnimationNodeStateMachinePlayback.travel<class_AnimationNodeStateMachinePlayback_method_travel>`, the animation is restarted. If ``false``, nothing happens on the teleportation to the self state.
  91. .. rst-class:: classref-section-separator
  92. ----
  93. .. rst-class:: classref-descriptions-group
  94. Method Descriptions
  95. -------------------
  96. .. _class_AnimationNodeStateMachine_method_add_node:
  97. .. rst-class:: classref-method
  98. void **add_node** **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationNode<class_AnimationNode>` node, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)**
  99. Adds a new node to the graph. The ``position`` is used for display in the editor.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_AnimationNodeStateMachine_method_add_transition:
  103. .. rst-class:: classref-method
  104. void **add_transition** **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)**
  105. Adds a transition between the given nodes.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_AnimationNodeStateMachine_method_get_graph_offset:
  109. .. rst-class:: classref-method
  110. :ref:`Vector2<class_Vector2>` **get_graph_offset** **(** **)** |const|
  111. Returns the draw offset of the graph. Used for display in the editor.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_AnimationNodeStateMachine_method_get_node:
  115. .. rst-class:: classref-method
  116. :ref:`AnimationNode<class_AnimationNode>` **get_node** **(** :ref:`StringName<class_StringName>` name **)** |const|
  117. Returns the animation node with the given name.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_AnimationNodeStateMachine_method_get_node_name:
  121. .. rst-class:: classref-method
  122. :ref:`StringName<class_StringName>` **get_node_name** **(** :ref:`AnimationNode<class_AnimationNode>` node **)** |const|
  123. Returns the given animation node's name.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_AnimationNodeStateMachine_method_get_node_position:
  127. .. rst-class:: classref-method
  128. :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`StringName<class_StringName>` name **)** |const|
  129. Returns the given node's coordinates. Used for display in the editor.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_AnimationNodeStateMachine_method_get_transition:
  133. .. rst-class:: classref-method
  134. :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` **get_transition** **(** :ref:`int<class_int>` idx **)** |const|
  135. Returns the given transition.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_AnimationNodeStateMachine_method_get_transition_count:
  139. .. rst-class:: classref-method
  140. :ref:`int<class_int>` **get_transition_count** **(** **)** |const|
  141. Returns the number of connections in the graph.
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. _class_AnimationNodeStateMachine_method_get_transition_from:
  145. .. rst-class:: classref-method
  146. :ref:`StringName<class_StringName>` **get_transition_from** **(** :ref:`int<class_int>` idx **)** |const|
  147. Returns the given transition's start node.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_AnimationNodeStateMachine_method_get_transition_to:
  151. .. rst-class:: classref-method
  152. :ref:`StringName<class_StringName>` **get_transition_to** **(** :ref:`int<class_int>` idx **)** |const|
  153. Returns the given transition's end node.
  154. .. rst-class:: classref-item-separator
  155. ----
  156. .. _class_AnimationNodeStateMachine_method_has_node:
  157. .. rst-class:: classref-method
  158. :ref:`bool<class_bool>` **has_node** **(** :ref:`StringName<class_StringName>` name **)** |const|
  159. Returns ``true`` if the graph contains the given node.
  160. .. rst-class:: classref-item-separator
  161. ----
  162. .. _class_AnimationNodeStateMachine_method_has_transition:
  163. .. rst-class:: classref-method
  164. :ref:`bool<class_bool>` **has_transition** **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to **)** |const|
  165. Returns ``true`` if there is a transition between the given nodes.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_AnimationNodeStateMachine_method_remove_node:
  169. .. rst-class:: classref-method
  170. void **remove_node** **(** :ref:`StringName<class_StringName>` name **)**
  171. Deletes the given node from the graph.
  172. .. rst-class:: classref-item-separator
  173. ----
  174. .. _class_AnimationNodeStateMachine_method_remove_transition:
  175. .. rst-class:: classref-method
  176. void **remove_transition** **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to **)**
  177. Deletes the transition between the two specified nodes.
  178. .. rst-class:: classref-item-separator
  179. ----
  180. .. _class_AnimationNodeStateMachine_method_remove_transition_by_index:
  181. .. rst-class:: classref-method
  182. void **remove_transition_by_index** **(** :ref:`int<class_int>` idx **)**
  183. Deletes the given transition by index.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_AnimationNodeStateMachine_method_rename_node:
  187. .. rst-class:: classref-method
  188. void **rename_node** **(** :ref:`StringName<class_StringName>` name, :ref:`StringName<class_StringName>` new_name **)**
  189. Renames the given node.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_AnimationNodeStateMachine_method_replace_node:
  193. .. rst-class:: classref-method
  194. void **replace_node** **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationNode<class_AnimationNode>` node **)**
  195. .. container:: contribute
  196. There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_AnimationNodeStateMachine_method_set_graph_offset:
  200. .. rst-class:: classref-method
  201. void **set_graph_offset** **(** :ref:`Vector2<class_Vector2>` offset **)**
  202. Sets the draw offset of the graph. Used for display in the editor.
  203. .. rst-class:: classref-item-separator
  204. ----
  205. .. _class_AnimationNodeStateMachine_method_set_node_position:
  206. .. rst-class:: classref-method
  207. void **set_node_position** **(** :ref:`StringName<class_StringName>` name, :ref:`Vector2<class_Vector2>` position **)**
  208. Sets the node's coordinates. Used for display in the editor.
  209. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  210. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  211. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  212. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  213. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  214. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`