AnimationNodeStateMachine

Inherits: AnimationRootNode < AnimationNode < Resource < RefCounted < 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 AnimationNodeStateMachinePlayback object from the AnimationTree node to control it programmatically.

Example:

var state_machine = $AnimationTree.get("parameters/playback")
state_machine.travel("some_state")

Tutorials

Methods

void

add_node ( StringName name, AnimationNode node, Vector2 position=Vector2(0, 0) )

void

add_transition ( StringName from, StringName to, AnimationNodeStateMachineTransition transition )

String

get_end_node ( ) const

Vector2

get_graph_offset ( ) const

AnimationNode

get_node ( StringName name ) const

StringName

get_node_name ( AnimationNode node ) const

Vector2

get_node_position ( StringName name ) const

String

get_start_node ( ) const

AnimationNodeStateMachineTransition

get_transition ( int idx ) const

int

get_transition_count ( ) const

StringName

get_transition_from ( int idx ) const

StringName

get_transition_to ( int idx ) const

bool

has_node ( StringName name ) const

bool

has_transition ( StringName from, StringName to ) const

void

remove_node ( StringName name )

void

remove_transition ( StringName from, StringName to )

void

remove_transition_by_index ( int idx )

void

rename_node ( StringName name, StringName new_name )

void

replace_node ( StringName name, AnimationNode node )

void

set_end_node ( StringName name )

void

set_graph_offset ( Vector2 offset )

void

set_node_position ( StringName name, Vector2 position )

void

set_start_node ( StringName name )

Method Descriptions

Adds a new node to the graph. The position is used for display in the editor.


Adds a transition between the given nodes.


  • String get_end_node ( ) const

Returns the graph's end node.


  • Vector2 get_graph_offset ( ) const

Returns the draw offset of the graph. Used for display in the editor.


Returns the animation node with the given name.


Returns the given animation node's name.


Returns the given node's coordinates. Used for display in the editor.


  • String get_start_node ( ) const

Returns the graph's end node.


Returns the given transition.


  • int get_transition_count ( ) const

Returns the number of connections in the graph.


Returns the given transition's start node.


Returns the given transition's end node.


Returns true if the graph contains the given node.


Returns true if there is a transition between the given nodes.


Deletes the given node from the graph.


Deletes the transition between the two specified nodes.


  • void remove_transition_by_index ( int idx )

Deletes the given transition by index.


Renames the given node.



Sets the given node as the graph end point.


  • void set_graph_offset ( Vector2 offset )

Sets the draw offset of the graph. Used for display in the editor.


Sets the node's coordinates. Used for display in the editor.


Sets the given node as the graph start point.