class_animationnodestatemachine.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/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. State machine for control of animations.
  11. Description
  12. -----------
  13. 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.
  14. \ **Example:**\
  15. .. tabs::
  16. .. code-tab:: gdscript
  17. var state_machine = $AnimationTree.get("parameters/playback")
  18. state_machine.travel("some_state")
  19. .. code-tab:: csharp
  20. var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback;
  21. stateMachine.Travel("some_state");
  22. Tutorials
  23. ---------
  24. - :doc:`AnimationTree <../tutorials/animation/animation_tree>`
  25. Methods
  26. -------
  27. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | 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) **)** |
  29. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`add_transition<class_AnimationNodeStateMachine_method_add_transition>` **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)** |
  31. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Vector2<class_Vector2>` | :ref:`get_graph_offset<class_AnimationNodeStateMachine_method_get_graph_offset>` **(** **)** |const| |
  33. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`AnimationNode<class_AnimationNode>` | :ref:`get_node<class_AnimationNodeStateMachine_method_get_node>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  35. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`StringName<class_StringName>` | :ref:`get_node_name<class_AnimationNodeStateMachine_method_get_node_name>` **(** :ref:`AnimationNode<class_AnimationNode>` node **)** |const| |
  37. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Vector2<class_Vector2>` | :ref:`get_node_position<class_AnimationNodeStateMachine_method_get_node_position>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  39. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` | :ref:`get_transition<class_AnimationNodeStateMachine_method_get_transition>` **(** :ref:`int<class_int>` idx **)** |const| |
  41. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_transition_count<class_AnimationNodeStateMachine_method_get_transition_count>` **(** **)** |const| |
  43. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`StringName<class_StringName>` | :ref:`get_transition_from<class_AnimationNodeStateMachine_method_get_transition_from>` **(** :ref:`int<class_int>` idx **)** |const| |
  45. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`StringName<class_StringName>` | :ref:`get_transition_to<class_AnimationNodeStateMachine_method_get_transition_to>` **(** :ref:`int<class_int>` idx **)** |const| |
  47. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`has_node<class_AnimationNodeStateMachine_method_has_node>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  49. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`has_transition<class_AnimationNodeStateMachine_method_has_transition>` **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to **)** |const| |
  51. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`remove_node<class_AnimationNodeStateMachine_method_remove_node>` **(** :ref:`StringName<class_StringName>` name **)** |
  53. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`remove_transition<class_AnimationNodeStateMachine_method_remove_transition>` **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to **)** |
  55. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`remove_transition_by_index<class_AnimationNodeStateMachine_method_remove_transition_by_index>` **(** :ref:`int<class_int>` idx **)** |
  57. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`rename_node<class_AnimationNodeStateMachine_method_rename_node>` **(** :ref:`StringName<class_StringName>` name, :ref:`StringName<class_StringName>` new_name **)** |
  59. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`replace_node<class_AnimationNodeStateMachine_method_replace_node>` **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationNode<class_AnimationNode>` node **)** |
  61. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set_graph_offset<class_AnimationNodeStateMachine_method_set_graph_offset>` **(** :ref:`Vector2<class_Vector2>` offset **)** |
  63. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`set_node_position<class_AnimationNodeStateMachine_method_set_node_position>` **(** :ref:`StringName<class_StringName>` name, :ref:`Vector2<class_Vector2>` position **)** |
  65. +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. Method Descriptions
  67. -------------------
  68. .. _class_AnimationNodeStateMachine_method_add_node:
  69. - void **add_node** **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationNode<class_AnimationNode>` node, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)**
  70. Adds a new node to the graph. The ``position`` is used for display in the editor.
  71. ----
  72. .. _class_AnimationNodeStateMachine_method_add_transition:
  73. - void **add_transition** **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)**
  74. Adds a transition between the given nodes.
  75. ----
  76. .. _class_AnimationNodeStateMachine_method_get_graph_offset:
  77. - :ref:`Vector2<class_Vector2>` **get_graph_offset** **(** **)** |const|
  78. Returns the draw offset of the graph. Used for display in the editor.
  79. ----
  80. .. _class_AnimationNodeStateMachine_method_get_node:
  81. - :ref:`AnimationNode<class_AnimationNode>` **get_node** **(** :ref:`StringName<class_StringName>` name **)** |const|
  82. Returns the animation node with the given name.
  83. ----
  84. .. _class_AnimationNodeStateMachine_method_get_node_name:
  85. - :ref:`StringName<class_StringName>` **get_node_name** **(** :ref:`AnimationNode<class_AnimationNode>` node **)** |const|
  86. Returns the given animation node's name.
  87. ----
  88. .. _class_AnimationNodeStateMachine_method_get_node_position:
  89. - :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`StringName<class_StringName>` name **)** |const|
  90. Returns the given node's coordinates. Used for display in the editor.
  91. ----
  92. .. _class_AnimationNodeStateMachine_method_get_transition:
  93. - :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` **get_transition** **(** :ref:`int<class_int>` idx **)** |const|
  94. Returns the given transition.
  95. ----
  96. .. _class_AnimationNodeStateMachine_method_get_transition_count:
  97. - :ref:`int<class_int>` **get_transition_count** **(** **)** |const|
  98. Returns the number of connections in the graph.
  99. ----
  100. .. _class_AnimationNodeStateMachine_method_get_transition_from:
  101. - :ref:`StringName<class_StringName>` **get_transition_from** **(** :ref:`int<class_int>` idx **)** |const|
  102. Returns the given transition's start node.
  103. ----
  104. .. _class_AnimationNodeStateMachine_method_get_transition_to:
  105. - :ref:`StringName<class_StringName>` **get_transition_to** **(** :ref:`int<class_int>` idx **)** |const|
  106. Returns the given transition's end node.
  107. ----
  108. .. _class_AnimationNodeStateMachine_method_has_node:
  109. - :ref:`bool<class_bool>` **has_node** **(** :ref:`StringName<class_StringName>` name **)** |const|
  110. Returns ``true`` if the graph contains the given node.
  111. ----
  112. .. _class_AnimationNodeStateMachine_method_has_transition:
  113. - :ref:`bool<class_bool>` **has_transition** **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to **)** |const|
  114. Returns ``true`` if there is a transition between the given nodes.
  115. ----
  116. .. _class_AnimationNodeStateMachine_method_remove_node:
  117. - void **remove_node** **(** :ref:`StringName<class_StringName>` name **)**
  118. Deletes the given node from the graph.
  119. ----
  120. .. _class_AnimationNodeStateMachine_method_remove_transition:
  121. - void **remove_transition** **(** :ref:`StringName<class_StringName>` from, :ref:`StringName<class_StringName>` to **)**
  122. Deletes the transition between the two specified nodes.
  123. ----
  124. .. _class_AnimationNodeStateMachine_method_remove_transition_by_index:
  125. - void **remove_transition_by_index** **(** :ref:`int<class_int>` idx **)**
  126. Deletes the given transition by index.
  127. ----
  128. .. _class_AnimationNodeStateMachine_method_rename_node:
  129. - void **rename_node** **(** :ref:`StringName<class_StringName>` name, :ref:`StringName<class_StringName>` new_name **)**
  130. Renames the given node.
  131. ----
  132. .. _class_AnimationNodeStateMachine_method_replace_node:
  133. - void **replace_node** **(** :ref:`StringName<class_StringName>` name, :ref:`AnimationNode<class_AnimationNode>` node **)**
  134. ----
  135. .. _class_AnimationNodeStateMachine_method_set_graph_offset:
  136. - void **set_graph_offset** **(** :ref:`Vector2<class_Vector2>` offset **)**
  137. Sets the draw offset of the graph. Used for display in the editor.
  138. ----
  139. .. _class_AnimationNodeStateMachine_method_set_node_position:
  140. - void **set_node_position** **(** :ref:`StringName<class_StringName>` name, :ref:`Vector2<class_Vector2>` position **)**
  141. Sets the node's coordinates. Used for display in the editor.
  142. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  143. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  144. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  145. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  146. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  147. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`