Class reference

AnimationNodeStateMachine

Inherits AnimationRootNode

A state machine with multiple AnimationRootNodes, used by AnimationTree.

Description

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")
		
		var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback;
		stateMachine.Travel("some_state");
		

Properties

bool reset_ends = false

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.

Methods

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

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

Vector2 get_graph_offset() const

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

StringName[] get_node_list() const

Returns a list containing the names of all animation nodes in this state machine.

Vector2 get_node_position(StringName name) const

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

int get_transition_count() const

Returns the number of connections in the graph.

StringName get_transition_from(int idx) const

Returns the given transition's start node.

StringName get_transition_to(int idx) const

Returns the given transition's end node.

bool has_node(StringName name) const

Returns true if the graph contains the given animation node.

bool has_transition(StringName from, StringName to) const

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

void remove_node(StringName name)

Deletes the given animation node from the graph.

void remove_transition(StringName from, StringName to)

Deletes the transition between the two specified animation nodes.

void remove_transition_by_index(int idx)

Deletes the given transition by index.

void set_graph_offset(Vector2 offset)

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

void set_node_position(StringName name, Vector2 position)

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

Constants

STATE_MACHINE_TYPE_ROOT = 0

Enum: StateMachineType

Seeking to the beginning is treated as playing from the start state. Transition to the end state is treated as exiting the state machine.

STATE_MACHINE_TYPE_NESTED = 1

Enum: StateMachineType

Seeking to the beginning is treated as seeking to the beginning of the animation in the current state. Transition to the end state, or the absence of transitions in each state, is treated as exiting the state machine.

Tutorials

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.