:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the AnimationNodeStateMachine.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_AnimationNodeStateMachine: AnimationNodeStateMachine ========================= **Inherits:** :ref:`AnimationRootNode` **<** :ref:`AnimationNode` **<** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` State machine for control of animations. Description ----------- 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` object from the :ref:`AnimationTree` node to control it programmatically. **Example:** :: var state_machine = $AnimationTree.get("parameters/playback") state_machine.travel("some_state") Tutorials --------- - :doc:`../tutorials/animation/animation_tree` Methods ------- +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_node` **(** :ref:`StringName` name, :ref:`AnimationNode` node, :ref:`Vector2` position=Vector2( 0, 0 ) **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_transition` **(** :ref:`StringName` from, :ref:`StringName` to, :ref:`AnimationNodeStateMachineTransition` transition **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_end_node` **(** **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_graph_offset` **(** **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`AnimationNode` | :ref:`get_node` **(** :ref:`StringName` name **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`get_node_name` **(** :ref:`AnimationNode` node **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_node_position` **(** :ref:`StringName` name **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_start_node` **(** **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`AnimationNodeStateMachineTransition` | :ref:`get_transition` **(** :ref:`int` idx **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_transition_count` **(** **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`get_transition_from` **(** :ref:`int` idx **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`get_transition_to` **(** :ref:`int` idx **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_node` **(** :ref:`StringName` name **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_transition` **(** :ref:`StringName` from, :ref:`StringName` to **)** const | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_node` **(** :ref:`StringName` name **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_transition` **(** :ref:`StringName` from, :ref:`StringName` to **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_transition_by_index` **(** :ref:`int` idx **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`rename_node` **(** :ref:`StringName` name, :ref:`StringName` new_name **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`replace_node` **(** :ref:`StringName` name, :ref:`AnimationNode` node **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_end_node` **(** :ref:`StringName` name **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_graph_offset` **(** :ref:`Vector2` offset **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_node_position` **(** :ref:`StringName` name, :ref:`Vector2` position **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_start_node` **(** :ref:`StringName` name **)** | +---------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Method Descriptions ------------------- .. _class_AnimationNodeStateMachine_method_add_node: - void **add_node** **(** :ref:`StringName` name, :ref:`AnimationNode` node, :ref:`Vector2` position=Vector2( 0, 0 ) **)** Adds a new node to the graph. The ``position`` is used for display in the editor. ---- .. _class_AnimationNodeStateMachine_method_add_transition: - void **add_transition** **(** :ref:`StringName` from, :ref:`StringName` to, :ref:`AnimationNodeStateMachineTransition` transition **)** Adds a transition between the given nodes. ---- .. _class_AnimationNodeStateMachine_method_get_end_node: - :ref:`String` **get_end_node** **(** **)** const Returns the graph's end node. ---- .. _class_AnimationNodeStateMachine_method_get_graph_offset: - :ref:`Vector2` **get_graph_offset** **(** **)** const Returns the draw offset of the graph. Used for display in the editor. ---- .. _class_AnimationNodeStateMachine_method_get_node: - :ref:`AnimationNode` **get_node** **(** :ref:`StringName` name **)** const Returns the animation node with the given name. ---- .. _class_AnimationNodeStateMachine_method_get_node_name: - :ref:`StringName` **get_node_name** **(** :ref:`AnimationNode` node **)** const Returns the given animation node's name. ---- .. _class_AnimationNodeStateMachine_method_get_node_position: - :ref:`Vector2` **get_node_position** **(** :ref:`StringName` name **)** const Returns the given node's coordinates. Used for display in the editor. ---- .. _class_AnimationNodeStateMachine_method_get_start_node: - :ref:`String` **get_start_node** **(** **)** const Returns the graph's end node. ---- .. _class_AnimationNodeStateMachine_method_get_transition: - :ref:`AnimationNodeStateMachineTransition` **get_transition** **(** :ref:`int` idx **)** const Returns the given transition. ---- .. _class_AnimationNodeStateMachine_method_get_transition_count: - :ref:`int` **get_transition_count** **(** **)** const Returns the number of connections in the graph. ---- .. _class_AnimationNodeStateMachine_method_get_transition_from: - :ref:`StringName` **get_transition_from** **(** :ref:`int` idx **)** const Returns the given transition's start node. ---- .. _class_AnimationNodeStateMachine_method_get_transition_to: - :ref:`StringName` **get_transition_to** **(** :ref:`int` idx **)** const Returns the given transition's end node. ---- .. _class_AnimationNodeStateMachine_method_has_node: - :ref:`bool` **has_node** **(** :ref:`StringName` name **)** const Returns ``true`` if the graph contains the given node. ---- .. _class_AnimationNodeStateMachine_method_has_transition: - :ref:`bool` **has_transition** **(** :ref:`StringName` from, :ref:`StringName` to **)** const Returns ``true`` if there is a transition between the given nodes. ---- .. _class_AnimationNodeStateMachine_method_remove_node: - void **remove_node** **(** :ref:`StringName` name **)** Deletes the given node from the graph. ---- .. _class_AnimationNodeStateMachine_method_remove_transition: - void **remove_transition** **(** :ref:`StringName` from, :ref:`StringName` to **)** Deletes the transition between the two specified nodes. ---- .. _class_AnimationNodeStateMachine_method_remove_transition_by_index: - void **remove_transition_by_index** **(** :ref:`int` idx **)** Deletes the given transition by index. ---- .. _class_AnimationNodeStateMachine_method_rename_node: - void **rename_node** **(** :ref:`StringName` name, :ref:`StringName` new_name **)** Renames the given node. ---- .. _class_AnimationNodeStateMachine_method_replace_node: - void **replace_node** **(** :ref:`StringName` name, :ref:`AnimationNode` node **)** ---- .. _class_AnimationNodeStateMachine_method_set_end_node: - void **set_end_node** **(** :ref:`StringName` name **)** Sets the given node as the graph end point. ---- .. _class_AnimationNodeStateMachine_method_set_graph_offset: - void **set_graph_offset** **(** :ref:`Vector2` offset **)** Sets the draw offset of the graph. Used for display in the editor. ---- .. _class_AnimationNodeStateMachine_method_set_node_position: - void **set_node_position** **(** :ref:`StringName` name, :ref:`Vector2` position **)** Sets the node's coordinates. Used for display in the editor. ---- .. _class_AnimationNodeStateMachine_method_set_start_node: - void **set_start_node** **(** :ref:`StringName` name **)** Sets the given node as the graph start point.