class_animationnodestatemachine.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the 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 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. Methods
  18. -------
  19. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | 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 ) **)** |
  21. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`add_transition<class_AnimationNodeStateMachine_method_add_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)** |
  23. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`String<class_String>` | :ref:`get_end_node<class_AnimationNodeStateMachine_method_get_end_node>` **(** **)** const |
  25. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Vector2<class_Vector2>` | :ref:`get_graph_offset<class_AnimationNodeStateMachine_method_get_graph_offset>` **(** **)** const |
  27. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`AnimationNode<class_AnimationNode>` | :ref:`get_node<class_AnimationNodeStateMachine_method_get_node>` **(** :ref:`String<class_String>` name **)** const |
  29. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`String<class_String>` | :ref:`get_node_name<class_AnimationNodeStateMachine_method_get_node_name>` **(** :ref:`AnimationNode<class_AnimationNode>` node **)** const |
  31. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Vector2<class_Vector2>` | :ref:`get_node_position<class_AnimationNodeStateMachine_method_get_node_position>` **(** :ref:`String<class_String>` name **)** const |
  33. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`String<class_String>` | :ref:`get_start_node<class_AnimationNodeStateMachine_method_get_start_node>` **(** **)** const |
  35. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` | :ref:`get_transition<class_AnimationNodeStateMachine_method_get_transition>` **(** :ref:`int<class_int>` idx **)** const |
  37. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_transition_count<class_AnimationNodeStateMachine_method_get_transition_count>` **(** **)** const |
  39. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`String<class_String>` | :ref:`get_transition_from<class_AnimationNodeStateMachine_method_get_transition_from>` **(** :ref:`int<class_int>` idx **)** const |
  41. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`String<class_String>` | :ref:`get_transition_to<class_AnimationNodeStateMachine_method_get_transition_to>` **(** :ref:`int<class_int>` idx **)** const |
  43. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`has_node<class_AnimationNodeStateMachine_method_has_node>` **(** :ref:`String<class_String>` name **)** const |
  45. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`has_transition<class_AnimationNodeStateMachine_method_has_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** const |
  47. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`remove_node<class_AnimationNodeStateMachine_method_remove_node>` **(** :ref:`String<class_String>` name **)** |
  49. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`remove_transition<class_AnimationNodeStateMachine_method_remove_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |
  51. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`remove_transition_by_index<class_AnimationNodeStateMachine_method_remove_transition_by_index>` **(** :ref:`int<class_int>` idx **)** |
  53. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`rename_node<class_AnimationNodeStateMachine_method_rename_node>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` new_name **)** |
  55. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_end_node<class_AnimationNodeStateMachine_method_set_end_node>` **(** :ref:`String<class_String>` name **)** |
  57. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_graph_offset<class_AnimationNodeStateMachine_method_set_graph_offset>` **(** :ref:`Vector2<class_Vector2>` offset **)** |
  59. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_node_position<class_AnimationNodeStateMachine_method_set_node_position>` **(** :ref:`String<class_String>` name, :ref:`Vector2<class_Vector2>` position **)** |
  61. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set_start_node<class_AnimationNodeStateMachine_method_set_start_node>` **(** :ref:`String<class_String>` name **)** |
  63. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. Method Descriptions
  65. -------------------
  66. .. _class_AnimationNodeStateMachine_method_add_node:
  67. - void **add_node** **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node, :ref:`Vector2<class_Vector2>` position=Vector2( 0, 0 ) **)**
  68. Adds a new node to the graph. The ``position`` is used for display in the editor.
  69. ----
  70. .. _class_AnimationNodeStateMachine_method_add_transition:
  71. - void **add_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)**
  72. Adds a transition between the given nodes.
  73. ----
  74. .. _class_AnimationNodeStateMachine_method_get_end_node:
  75. - :ref:`String<class_String>` **get_end_node** **(** **)** const
  76. Returns the graph's end node.
  77. ----
  78. .. _class_AnimationNodeStateMachine_method_get_graph_offset:
  79. - :ref:`Vector2<class_Vector2>` **get_graph_offset** **(** **)** const
  80. Returns the draw offset of the graph. Used for display in the editor.
  81. ----
  82. .. _class_AnimationNodeStateMachine_method_get_node:
  83. - :ref:`AnimationNode<class_AnimationNode>` **get_node** **(** :ref:`String<class_String>` name **)** const
  84. Returns the animation node with the given name.
  85. ----
  86. .. _class_AnimationNodeStateMachine_method_get_node_name:
  87. - :ref:`String<class_String>` **get_node_name** **(** :ref:`AnimationNode<class_AnimationNode>` node **)** const
  88. Returns the given animation node's name.
  89. ----
  90. .. _class_AnimationNodeStateMachine_method_get_node_position:
  91. - :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`String<class_String>` name **)** const
  92. Returns the given node's coordinates. Used for display in the editor.
  93. ----
  94. .. _class_AnimationNodeStateMachine_method_get_start_node:
  95. - :ref:`String<class_String>` **get_start_node** **(** **)** const
  96. Returns the graph's end node.
  97. ----
  98. .. _class_AnimationNodeStateMachine_method_get_transition:
  99. - :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` **get_transition** **(** :ref:`int<class_int>` idx **)** const
  100. Returns the given transition.
  101. ----
  102. .. _class_AnimationNodeStateMachine_method_get_transition_count:
  103. - :ref:`int<class_int>` **get_transition_count** **(** **)** const
  104. Returns the number of connections in the graph.
  105. ----
  106. .. _class_AnimationNodeStateMachine_method_get_transition_from:
  107. - :ref:`String<class_String>` **get_transition_from** **(** :ref:`int<class_int>` idx **)** const
  108. Returns the given transition's start node.
  109. ----
  110. .. _class_AnimationNodeStateMachine_method_get_transition_to:
  111. - :ref:`String<class_String>` **get_transition_to** **(** :ref:`int<class_int>` idx **)** const
  112. Returns the given transition's end node.
  113. ----
  114. .. _class_AnimationNodeStateMachine_method_has_node:
  115. - :ref:`bool<class_bool>` **has_node** **(** :ref:`String<class_String>` name **)** const
  116. Returns ``true`` if the graph contains the given node.
  117. ----
  118. .. _class_AnimationNodeStateMachine_method_has_transition:
  119. - :ref:`bool<class_bool>` **has_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** const
  120. Returns ``true`` if there is a transition between the given nodes.
  121. ----
  122. .. _class_AnimationNodeStateMachine_method_remove_node:
  123. - void **remove_node** **(** :ref:`String<class_String>` name **)**
  124. Deletes the given node from the graph.
  125. ----
  126. .. _class_AnimationNodeStateMachine_method_remove_transition:
  127. - void **remove_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)**
  128. Deletes the given transition.
  129. ----
  130. .. _class_AnimationNodeStateMachine_method_remove_transition_by_index:
  131. - void **remove_transition_by_index** **(** :ref:`int<class_int>` idx **)**
  132. Deletes the given transition.
  133. ----
  134. .. _class_AnimationNodeStateMachine_method_rename_node:
  135. - void **rename_node** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` new_name **)**
  136. Renames the given node.
  137. ----
  138. .. _class_AnimationNodeStateMachine_method_set_end_node:
  139. - void **set_end_node** **(** :ref:`String<class_String>` name **)**
  140. Sets the given node as the graph end point.
  141. ----
  142. .. _class_AnimationNodeStateMachine_method_set_graph_offset:
  143. - void **set_graph_offset** **(** :ref:`Vector2<class_Vector2>` offset **)**
  144. Sets the draw offset of the graph. Used for display in the editor.
  145. ----
  146. .. _class_AnimationNodeStateMachine_method_set_node_position:
  147. - void **set_node_position** **(** :ref:`String<class_String>` name, :ref:`Vector2<class_Vector2>` position **)**
  148. Sets the node's coordinates. Used for display in the editor.
  149. ----
  150. .. _class_AnimationNodeStateMachine_method_set_start_node:
  151. - void **set_start_node** **(** :ref:`String<class_String>` name **)**
  152. Sets the given node as the graph start point.