Table of Contents

Class AnimationNodeStateMachine

Namespace
Godot
Assembly
GodotSharp.dll

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.

Example:

var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback;
  stateMachine.Travel("some_state");
public class AnimationNodeStateMachine : AnimationRootNode, IDisposable
Inheritance
AnimationNodeStateMachine
Implements
Inherited Members

Constructors

AnimationNodeStateMachine()

public AnimationNodeStateMachine()

Properties

AllowTransitionToSelf

If true, allows teleport to the self state with Travel(StringName, bool). When the reset option is enabled in Travel(StringName, bool), the animation is restarted. If false, nothing happens on the teleportation to the self state.

public bool AllowTransitionToSelf { get; set; }

Property Value

bool

ResetEnds

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.

public bool ResetEnds { get; set; }

Property Value

bool

StateMachineType

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

public AnimationNodeStateMachine.StateMachineTypeEnum StateMachineType { get; set; }

Property Value

AnimationNodeStateMachine.StateMachineTypeEnum

Methods

AddNode(StringName, AnimationNode, Vector2?)

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

public void AddNode(StringName name, AnimationNode node, Vector2? position = null)

Parameters

name StringName
node AnimationNode
position Vector2?

If the parameter is null, then the default value is new Vector2(0, 0).

AddTransition(StringName, StringName, AnimationNodeStateMachineTransition)

Adds a transition between the given animation nodes.

public void AddTransition(StringName from, StringName to, AnimationNodeStateMachineTransition transition)

Parameters

from StringName
to StringName
transition AnimationNodeStateMachineTransition

GetGraphOffset()

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

public Vector2 GetGraphOffset()

Returns

Vector2

GetNode(StringName)

Returns the animation node with the given name.

public AnimationNode GetNode(StringName name)

Parameters

name StringName

Returns

AnimationNode

GetNodeName(AnimationNode)

Returns the given animation node's name.

public StringName GetNodeName(AnimationNode node)

Parameters

node AnimationNode

Returns

StringName

GetNodePosition(StringName)

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

public Vector2 GetNodePosition(StringName name)

Parameters

name StringName

Returns

Vector2

GetTransition(int)

Returns the given transition.

public AnimationNodeStateMachineTransition GetTransition(int idx)

Parameters

idx int

Returns

AnimationNodeStateMachineTransition

GetTransitionCount()

Returns the number of connections in the graph.

public int GetTransitionCount()

Returns

int

GetTransitionFrom(int)

Returns the given transition's start node.

public StringName GetTransitionFrom(int idx)

Parameters

idx int

Returns

StringName

GetTransitionTo(int)

Returns the given transition's end node.

public StringName GetTransitionTo(int idx)

Parameters

idx int

Returns

StringName

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

HasNode(StringName)

Returns true if the graph contains the given animation node.

public bool HasNode(StringName name)

Parameters

name StringName

Returns

bool

HasTransition(StringName, StringName)

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

public bool HasTransition(StringName from, StringName to)

Parameters

from StringName
to StringName

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

RemoveNode(StringName)

Deletes the given animation node from the graph.

public void RemoveNode(StringName name)

Parameters

name StringName

RemoveTransition(StringName, StringName)

Deletes the transition between the two specified animation nodes.

public void RemoveTransition(StringName from, StringName to)

Parameters

from StringName
to StringName

RemoveTransitionByIndex(int)

Deletes the given transition by index.

public void RemoveTransitionByIndex(int idx)

Parameters

idx int

RenameNode(StringName, StringName)

Renames the given animation node.

public void RenameNode(StringName name, StringName newName)

Parameters

name StringName
newName StringName

ReplaceNode(StringName, AnimationNode)

public void ReplaceNode(StringName name, AnimationNode node)

Parameters

name StringName
node AnimationNode

SetGraphOffset(Vector2)

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

public void SetGraphOffset(Vector2 offset)

Parameters

offset Vector2

SetNodePosition(StringName, Vector2)

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

public void SetNodePosition(StringName name, Vector2 position)

Parameters

name StringName
position Vector2