class_animationnodestatemachine.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. **Category:** Core
  10. Brief Description
  11. -----------------
  12. State machine for control of animations.
  13. Methods
  14. -------
  15. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | 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 ) **)** |
  17. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`add_transition<class_AnimationNodeStateMachine_method_add_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)** |
  19. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`String<class_String>` | :ref:`get_end_node<class_AnimationNodeStateMachine_method_get_end_node>` **(** **)** const |
  21. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Vector2<class_Vector2>` | :ref:`get_graph_offset<class_AnimationNodeStateMachine_method_get_graph_offset>` **(** **)** const |
  23. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`AnimationNode<class_AnimationNode>` | :ref:`get_node<class_AnimationNodeStateMachine_method_get_node>` **(** :ref:`String<class_String>` name **)** const |
  25. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`String<class_String>` | :ref:`get_node_name<class_AnimationNodeStateMachine_method_get_node_name>` **(** :ref:`AnimationNode<class_AnimationNode>` node **)** const |
  27. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Vector2<class_Vector2>` | :ref:`get_node_position<class_AnimationNodeStateMachine_method_get_node_position>` **(** :ref:`String<class_String>` name **)** const |
  29. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`String<class_String>` | :ref:`get_start_node<class_AnimationNodeStateMachine_method_get_start_node>` **(** **)** const |
  31. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` | :ref:`get_transition<class_AnimationNodeStateMachine_method_get_transition>` **(** :ref:`int<class_int>` idx **)** const |
  33. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_transition_count<class_AnimationNodeStateMachine_method_get_transition_count>` **(** **)** const |
  35. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`String<class_String>` | :ref:`get_transition_from<class_AnimationNodeStateMachine_method_get_transition_from>` **(** :ref:`int<class_int>` idx **)** const |
  37. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`String<class_String>` | :ref:`get_transition_to<class_AnimationNodeStateMachine_method_get_transition_to>` **(** :ref:`int<class_int>` idx **)** const |
  39. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`bool<class_bool>` | :ref:`has_node<class_AnimationNodeStateMachine_method_has_node>` **(** :ref:`String<class_String>` name **)** const |
  41. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`has_transition<class_AnimationNodeStateMachine_method_has_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** const |
  43. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`remove_node<class_AnimationNodeStateMachine_method_remove_node>` **(** :ref:`String<class_String>` name **)** |
  45. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`remove_transition<class_AnimationNodeStateMachine_method_remove_transition>` **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** |
  47. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`remove_transition_by_index<class_AnimationNodeStateMachine_method_remove_transition_by_index>` **(** :ref:`int<class_int>` idx **)** |
  49. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`rename_node<class_AnimationNodeStateMachine_method_rename_node>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` new_name **)** |
  51. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_end_node<class_AnimationNodeStateMachine_method_set_end_node>` **(** :ref:`String<class_String>` name **)** |
  53. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_graph_offset<class_AnimationNodeStateMachine_method_set_graph_offset>` **(** :ref:`Vector2<class_Vector2>` offset **)** |
  55. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_node_position<class_AnimationNodeStateMachine_method_set_node_position>` **(** :ref:`String<class_String>` name, :ref:`Vector2<class_Vector2>` position **)** |
  57. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_start_node<class_AnimationNodeStateMachine_method_set_start_node>` **(** :ref:`String<class_String>` name **)** |
  59. +---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. Description
  61. -----------
  62. 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.
  63. **Example:**
  64. ::
  65. var state_machine = $AnimationTree.get("parameters/playback")
  66. state_machine.travel("some_state")
  67. Method Descriptions
  68. -------------------
  69. .. _class_AnimationNodeStateMachine_method_add_node:
  70. - void **add_node** **(** :ref:`String<class_String>` name, :ref:`AnimationNode<class_AnimationNode>` node, :ref:`Vector2<class_Vector2>` position=Vector2( 0, 0 ) **)**
  71. Adds a new node to the graph. The ``position`` is used for display in the editor.
  72. .. _class_AnimationNodeStateMachine_method_add_transition:
  73. - void **add_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to, :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` transition **)**
  74. Adds a transition between the given nodes.
  75. .. _class_AnimationNodeStateMachine_method_get_end_node:
  76. - :ref:`String<class_String>` **get_end_node** **(** **)** const
  77. Returns the graph's end node.
  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. .. _class_AnimationNodeStateMachine_method_get_node:
  82. - :ref:`AnimationNode<class_AnimationNode>` **get_node** **(** :ref:`String<class_String>` name **)** const
  83. Returns the animation node with the given name.
  84. .. _class_AnimationNodeStateMachine_method_get_node_name:
  85. - :ref:`String<class_String>` **get_node_name** **(** :ref:`AnimationNode<class_AnimationNode>` node **)** const
  86. Returns the given animation node's name.
  87. .. _class_AnimationNodeStateMachine_method_get_node_position:
  88. - :ref:`Vector2<class_Vector2>` **get_node_position** **(** :ref:`String<class_String>` name **)** const
  89. Returns the given node's coordinates. Used for display in the editor.
  90. .. _class_AnimationNodeStateMachine_method_get_start_node:
  91. - :ref:`String<class_String>` **get_start_node** **(** **)** const
  92. Returns the graph's end node.
  93. .. _class_AnimationNodeStateMachine_method_get_transition:
  94. - :ref:`AnimationNodeStateMachineTransition<class_AnimationNodeStateMachineTransition>` **get_transition** **(** :ref:`int<class_int>` idx **)** const
  95. Returns the given transition.
  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. .. _class_AnimationNodeStateMachine_method_get_transition_from:
  100. - :ref:`String<class_String>` **get_transition_from** **(** :ref:`int<class_int>` idx **)** const
  101. Returns the given transition's start node.
  102. .. _class_AnimationNodeStateMachine_method_get_transition_to:
  103. - :ref:`String<class_String>` **get_transition_to** **(** :ref:`int<class_int>` idx **)** const
  104. Returns the given transition's end node.
  105. .. _class_AnimationNodeStateMachine_method_has_node:
  106. - :ref:`bool<class_bool>` **has_node** **(** :ref:`String<class_String>` name **)** const
  107. Returns ``true`` if the graph contains the given node.
  108. .. _class_AnimationNodeStateMachine_method_has_transition:
  109. - :ref:`bool<class_bool>` **has_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)** const
  110. Returns ``true`` if there is a transition between the given nodes.
  111. .. _class_AnimationNodeStateMachine_method_remove_node:
  112. - void **remove_node** **(** :ref:`String<class_String>` name **)**
  113. Deletes the given node from the graph.
  114. .. _class_AnimationNodeStateMachine_method_remove_transition:
  115. - void **remove_transition** **(** :ref:`String<class_String>` from, :ref:`String<class_String>` to **)**
  116. Deletes the given transition.
  117. .. _class_AnimationNodeStateMachine_method_remove_transition_by_index:
  118. - void **remove_transition_by_index** **(** :ref:`int<class_int>` idx **)**
  119. Deletes the given transition.
  120. .. _class_AnimationNodeStateMachine_method_rename_node:
  121. - void **rename_node** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` new_name **)**
  122. Renames the given node.
  123. .. _class_AnimationNodeStateMachine_method_set_end_node:
  124. - void **set_end_node** **(** :ref:`String<class_String>` name **)**
  125. Sets the given node as the graph end point.
  126. .. _class_AnimationNodeStateMachine_method_set_graph_offset:
  127. - void **set_graph_offset** **(** :ref:`Vector2<class_Vector2>` offset **)**
  128. Sets the draw offset of the graph. Used for display in the editor.
  129. .. _class_AnimationNodeStateMachine_method_set_node_position:
  130. - void **set_node_position** **(** :ref:`String<class_String>` name, :ref:`Vector2<class_Vector2>` position **)**
  131. Sets the node's coordinates. Used for display in the editor.
  132. .. _class_AnimationNodeStateMachine_method_set_start_node:
  133. - void **set_start_node** **(** :ref:`String<class_String>` name **)**
  134. Sets the given node as the graph start point.