Table of Contents

Class AnimationNodeStateMachine

A state machine with multiple AnimationRootNodes, used by AnimationTree.

Inheritance
AnimationNodeStateMachine

Remarks

Contains multiple AnimationRootNodes representing animation states, connected in a graph. State 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.

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

See Also

Properties

allow_transition_to_self

If true, allows teleport to the self state with AnimationNodeStateMachinePlayback.travel. When the reset option is enabled in AnimationNodeStateMachinePlayback.travel, the animation is restarted. If false, nothing happens on the teleportation to the self state.

var allow_transition_to_self : bool = false

Property Value

bool

Remarks

  • void set_allow_transition_to_self(bool value)
  • bool is_allow_transition_to_self

reset_ends

If true, treat the cross-fade to the start and end nodes as a blend with the RESET animation.

In most cases, when additional cross-fades are performed in the parent AnimationNode of the state machine, setting this property to false and matching the cross-fade time of the parent AnimationNode and the state machine's start node and end node gives good results.

var reset_ends : bool = false

Property Value

bool

Remarks

  • void set_reset_ends(bool value)
  • bool are_ends_reset

state_machine_type

This property can define the process of transitions for different use cases. See also StateMachineType.

var state_machine_type : int = 0

Property Value

int

Remarks

  • void set_state_machine_type(int value)
  • int get_state_machine_type

Methods

add_node(StringName, AnimationNode, Vector2)

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

void add_node(StringName name, AnimationNode node, Vector2 position)

Parameters

name StringName
node AnimationNode
position Vector2

add_transition(StringName, StringName, AnimationNodeStateMachineTransition)

Adds a transition between the given animation nodes.

void add_transition(StringName from, StringName to, AnimationNodeStateMachineTransition transition)

Parameters

from StringName
to StringName
transition AnimationNodeStateMachineTransition

get_graph_offset

Qualifiers: const

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

Vector2 get_graph_offset

get_node(StringName)

Qualifiers: const

Returns the animation node with the given name.

AnimationNode get_node(StringName name)

Parameters

name StringName

get_node_name(AnimationNode)

Qualifiers: const

Returns the given animation node's name.

StringName get_node_name(AnimationNode node)

Parameters

node AnimationNode

get_node_position(StringName)

Qualifiers: const

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

Vector2 get_node_position(StringName name)

Parameters

name StringName

get_transition(int)

Qualifiers: const

Returns the given transition.

AnimationNodeStateMachineTransition get_transition(int idx)

Parameters

idx int

get_transition_count

Qualifiers: const

Returns the number of connections in the graph.

int get_transition_count

get_transition_from(int)

Qualifiers: const

Returns the given transition's start node.

StringName get_transition_from(int idx)

Parameters

idx int

get_transition_to(int)

Qualifiers: const

Returns the given transition's end node.

StringName get_transition_to(int idx)

Parameters

idx int

has_node(StringName)

Qualifiers: const

Returns true if the graph contains the given animation node.

bool has_node(StringName name)

Parameters

name StringName

has_transition(StringName, StringName)

Qualifiers: const

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

bool has_transition(StringName from, StringName to)

Parameters

from StringName
to StringName

remove_node(StringName)

Deletes the given animation node from the graph.

void remove_node(StringName name)

Parameters

name StringName

remove_transition(StringName, StringName)

Deletes the transition between the two specified animation nodes.

void remove_transition(StringName from, StringName to)

Parameters

from StringName
to StringName

remove_transition_by_index(int)

Deletes the given transition by index.

void remove_transition_by_index(int idx)

Parameters

idx int

rename_node(StringName, StringName)

Renames the given animation node.

void rename_node(StringName name, StringName new_name)

Parameters

name StringName
new_name StringName

replace_node(StringName, AnimationNode)

Replaces the given animation node with a new animation node.

void replace_node(StringName name, AnimationNode node)

Parameters

name StringName
node AnimationNode

set_graph_offset(Vector2)

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

void set_graph_offset(Vector2 offset)

Parameters

offset Vector2

set_node_position(StringName, Vector2)

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

void set_node_position(StringName name, Vector2 position)

Parameters

name StringName
position Vector2