class_animationnodestatemachine.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the AnimationNodeStateMachine.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AnimationNodeStateMachine:
  6. AnimationNodeStateMachine
  7. =========================
  8. **Inherits:** :ref:`AnimationRootNode<class_AnimationRootNode>` **<** :ref:`AnimationNode<class_AnimationNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. State machine for control of animations.
  10. Description
  11. -----------
  12. 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.
  13. **Example:**
  14. ::
  15. var state_machine = $AnimationTree.get("parameters/playback")
  16. state_machine.travel("some_state")
  17. Tutorials
  18. ---------
  19. - :doc:`../tutorials/animation/animation_tree`
  20. Methods
  21. -------
  22. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | 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 ) **)** |
  24. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`add_transition<class_AnimationNodeStateMachine_method_add_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)** |
  26. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`String<class_String>` | :ref:`get_end_node<class_AnimationNodeStateMachine_method_get_end_node>` **(** **)** |const| |
  28. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Vector2<class_Vector2>` | :ref:`get_graph_offset<class_AnimationNodeStateMachine_method_get_graph_offset>` **(** **)** |const| |
  30. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`AnimationNode<class_AnimationNode>` | :ref:`get_node<class_AnimationNodeStateMachine_method_get_node>` **(** :ref:`String<class_String>` name **)** |const| |
  32. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`String<class_String>` | :ref:`get_node_name<class_AnimationNodeStateMachine_method_get_node_name>` **(** :ref:`AnimationNode<class_AnimationNode>` node **)** |const| |
  34. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Vector2<class_Vector2>` | :ref:`get_node_position<class_AnimationNodeStateMachine_method_get_node_position>` **(** :ref:`String<class_String>` name **)** |const| |
  36. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`String<class_String>` | :ref:`get_start_node<class_AnimationNodeStateMachine_method_get_start_node>` **(** **)** |const| |
  38. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` | :ref:`get_transition<class_AnimationNodeStateMachine_method_get_transition>` **(** :ref:`int<class_int>` idx **)** |const| |
  40. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`get_transition_count<class_AnimationNodeStateMachine_method_get_transition_count>` **(** **)** |const| |
  42. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`String<class_String>` | :ref:`get_transition_from<class_AnimationNodeStateMachine_method_get_transition_from>` **(** :ref:`int<class_int>` idx **)** |const| |
  44. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`String<class_String>` | :ref:`get_transition_to<class_AnimationNodeStateMachine_method_get_transition_to>` **(** :ref:`int<class_int>` idx **)** |const| |
  46. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`has_node<class_AnimationNodeStateMachine_method_has_node>` **(** :ref:`String<class_String>` name **)** |const| |
  48. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`has_transition<class_AnimationNodeStateMachine_method_has_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |const| |
  50. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`remove_node<class_AnimationNodeStateMachine_method_remove_node>` **(** :ref:`String<class_String>` name **)** |
  52. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`remove_transition<class_AnimationNodeStateMachine_method_remove_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |
  54. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`remove_transition_by_index<class_AnimationNodeStateMachine_method_remove_transition_by_index>` **(** :ref:`int<class_int>` idx **)** |
  56. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`rename_node<class_AnimationNodeStateMachine_method_rename_node>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` new_name **)** |
  58. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`replace_node<class_AnimationNodeStateMachine_method_replace_node>` **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node **)** |
  60. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_end_node<class_AnimationNodeStateMachine_method_set_end_node>` **(** :ref:`String<class_String>` name **)** |
  62. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_graph_offset<class_AnimationNodeStateMachine_method_set_graph_offset>` **(** :ref:`Vector2<class_Vector2>` offset **)** |
  64. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`set_node_position<class_AnimationNodeStateMachine_method_set_node_position>` **(** :ref:`String<class_String>` name, :ref:`Vector2<class_Vector2>` position **)** |
  66. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`set_start_node<class_AnimationNodeStateMachine_method_set_start_node>` **(** :ref:`String<class_String>` name **)** |
  68. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. Method Descriptions
  70. -------------------
  71. .. _class_AnimationNodeStateMachine_method_add_node:
  72. - void **add_node** **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node, :ref:`Vector2<class_Vector2>` position=Vector2( 0, 0 ) **)**
  73. Adds a new node to the graph. The ``position`` is used for display in the editor.
  74. ----
  75. .. _class_AnimationNodeStateMachine_method_add_transition:
  76. - void **add_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)**
  77. Adds a transition between the given nodes.
  78. ----
  79. .. _class_AnimationNodeStateMachine_method_get_end_node:
  80. - :ref:`String<class_String>` **get_end_node** **(** **)** |const|
  81. Returns the graph's end node.
  82. ----
  83. .. _class_AnimationNodeStateMachine_method_get_graph_offset:
  84. - :ref:`Vector2<class_Vector2>` **get_graph_offset** **(** **)** |const|
  85. Returns the draw offset of the graph. Used for display in the editor.
  86. ----
  87. .. _class_AnimationNodeStateMachine_method_get_node:
  88. - :ref:`AnimationNode<class_AnimationNode>` **get_node** **(** :ref:`String<class_String>` name **)** |const|
  89. Returns the animation node with the given name.
  90. ----
  91. .. _class_AnimationNodeStateMachine_method_get_node_name:
  92. - :ref:`String<class_String>` **get_node_name** **(** :ref:`AnimationNode<class_AnimationNode>` node **)** |const|
  93. Returns the given animation node's name.
  94. ----
  95. .. _class_AnimationNodeStateMachine_method_get_node_position:
  96. - :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`String<class_String>` name **)** |const|
  97. Returns the given node's coordinates. Used for display in the editor.
  98. ----
  99. .. _class_AnimationNodeStateMachine_method_get_start_node:
  100. - :ref:`String<class_String>` **get_start_node** **(** **)** |const|
  101. Returns the graph's end node.
  102. ----
  103. .. _class_AnimationNodeStateMachine_method_get_transition:
  104. - :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` **get_transition** **(** :ref:`int<class_int>` idx **)** |const|
  105. Returns the given transition.
  106. ----
  107. .. _class_AnimationNodeStateMachine_method_get_transition_count:
  108. - :ref:`int<class_int>` **get_transition_count** **(** **)** |const|
  109. Returns the number of connections in the graph.
  110. ----
  111. .. _class_AnimationNodeStateMachine_method_get_transition_from:
  112. - :ref:`String<class_String>` **get_transition_from** **(** :ref:`int<class_int>` idx **)** |const|
  113. Returns the given transition's start node.
  114. ----
  115. .. _class_AnimationNodeStateMachine_method_get_transition_to:
  116. - :ref:`String<class_String>` **get_transition_to** **(** :ref:`int<class_int>` idx **)** |const|
  117. Returns the given transition's end node.
  118. ----
  119. .. _class_AnimationNodeStateMachine_method_has_node:
  120. - :ref:`bool<class_bool>` **has_node** **(** :ref:`String<class_String>` name **)** |const|
  121. Returns ``true`` if the graph contains the given node.
  122. ----
  123. .. _class_AnimationNodeStateMachine_method_has_transition:
  124. - :ref:`bool<class_bool>` **has_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |const|
  125. Returns ``true`` if there is a transition between the given nodes.
  126. ----
  127. .. _class_AnimationNodeStateMachine_method_remove_node:
  128. - void **remove_node** **(** :ref:`String<class_String>` name **)**
  129. Deletes the given node from the graph.
  130. ----
  131. .. _class_AnimationNodeStateMachine_method_remove_transition:
  132. - void **remove_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)**
  133. Deletes the transition between the two specified nodes.
  134. ----
  135. .. _class_AnimationNodeStateMachine_method_remove_transition_by_index:
  136. - void **remove_transition_by_index** **(** :ref:`int<class_int>` idx **)**
  137. Deletes the given transition by index.
  138. ----
  139. .. _class_AnimationNodeStateMachine_method_rename_node:
  140. - void **rename_node** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` new_name **)**
  141. Renames the given node.
  142. ----
  143. .. _class_AnimationNodeStateMachine_method_replace_node:
  144. - void **replace_node** **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node **)**
  145. Replaces the node and keeps its transitions unchanged.
  146. ----
  147. .. _class_AnimationNodeStateMachine_method_set_end_node:
  148. - void **set_end_node** **(** :ref:`String<class_String>` name **)**
  149. Sets the given node as the graph end point.
  150. ----
  151. .. _class_AnimationNodeStateMachine_method_set_graph_offset:
  152. - void **set_graph_offset** **(** :ref:`Vector2<class_Vector2>` offset **)**
  153. Sets the draw offset of the graph. Used for display in the editor.
  154. ----
  155. .. _class_AnimationNodeStateMachine_method_set_node_position:
  156. - void **set_node_position** **(** :ref:`String<class_String>` name, :ref:`Vector2<class_Vector2>` position **)**
  157. Sets the node's coordinates. Used for display in the editor.
  158. ----
  159. .. _class_AnimationNodeStateMachine_method_set_start_node:
  160. - void **set_start_node** **(** :ref:`String<class_String>` name **)**
  161. Sets the given node as the graph start point.
  162. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  163. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  164. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`