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
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
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
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
StringNamenode
AnimationNodeposition
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
StringNameto
StringNametransition
AnimationNodeStateMachineTransition
GetGraphOffset()
Returns the draw offset of the graph. Used for display in the editor.
public Vector2 GetGraphOffset()
Returns
GetNode(StringName)
Returns the animation node with the given name.
public AnimationNode GetNode(StringName name)
Parameters
name
StringName
Returns
GetNodeName(AnimationNode)
Returns the given animation node's name.
public StringName GetNodeName(AnimationNode node)
Parameters
node
AnimationNode
Returns
GetNodePosition(StringName)
Returns the given animation node's coordinates. Used for display in the editor.
public Vector2 GetNodePosition(StringName name)
Parameters
name
StringName
Returns
GetTransition(int)
Returns the given transition.
public AnimationNodeStateMachineTransition GetTransition(int idx)
Parameters
idx
int
Returns
GetTransitionCount()
Returns the number of connections in the graph.
public int GetTransitionCount()
Returns
GetTransitionFrom(int)
Returns the given transition's start node.
public StringName GetTransitionFrom(int idx)
Parameters
idx
int
Returns
GetTransitionTo(int)
Returns the given transition's end node.
public StringName GetTransitionTo(int idx)
Parameters
idx
int
Returns
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
HasNode(StringName)
Returns true
if the graph contains the given animation node.
public bool HasNode(StringName name)
Parameters
name
StringName
Returns
HasTransition(StringName, StringName)
Returns true
if there is a transition between the given animation nodes.
public bool HasTransition(StringName from, StringName to)
Parameters
from
StringNameto
StringName
Returns
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
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
StringNameto
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
StringNamenewName
StringName
ReplaceNode(StringName, AnimationNode)
public void ReplaceNode(StringName name, AnimationNode node)
Parameters
name
StringNamenode
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
StringNameposition
Vector2