AnimationNodeStateMachine
A state machine with multiple AnimationRootNodes, used by AnimationTree.
A state machine with multiple AnimationRootNodes, used by AnimationTree.
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 stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback;
stateMachine.Travel("some_state");Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
AnimationNodeStateMachineConstructor
public AnimationNodeStateMachine();Properties3
AllowTransitionToSelfProperty
public bool AllowTransitionToSelf { get; set; }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.
ResetEndsProperty
public bool ResetEnds { get; set; }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.
StateMachineTypeProperty
public AnimationNodeStateMachine.StateMachineTypeEnum StateMachineType { get; set; }This property can define the process of transitions for different use cases. See also AnimationNodeStateMachine.StateMachineTypeEnum.
Methods26
AddNodevoid
public void AddNode(StringName name, AnimationNode node, Vector2? position = default);Adds a new animation node to the graph. The position is used for display in the editor.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
node | AnimationNode | — |
position | Vector2? | default |
positionIf the parameter is null, then the default value is new Vector2(0.0f, 0.0f).
AddTransitionvoid
public void AddTransition(StringName from, StringName to, AnimationNodeStateMachineTransition transition);Adds a transition between the given animation nodes.
| Name | Type | Default |
|---|---|---|
from | StringName | — |
to | StringName | — |
transition | AnimationNodeStateMachineTransition | — |
AreEndsResetbool
public bool AreEndsReset();boolGetGraphOffsetVector2
public Vector2 GetGraphOffset();Returns the draw offset of the graph. Used for display in the editor.
Vector2GetNodeAnimationNode
public AnimationNode GetNode(StringName name);Returns the animation node with the given name.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
AnimationNodeGetNodeListReckfell.Collections.Array<StringName>
public Reckfell.Collections.Array<StringName> GetNodeList();Returns a list containing the names of all animation nodes in this state machine.
Reckfell.Collections.Array<StringName>GetNodeNameStringName
public StringName GetNodeName(AnimationNode node);Returns the given animation node's name.
| Name | Type | Default |
|---|---|---|
node | AnimationNode | — |
StringNameGetNodePositionVector2
public Vector2 GetNodePosition(StringName name);Returns the given animation node's coordinates. Used for display in the editor.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
Vector2GetStateMachineTypeAnimationNodeStateMachine.StateMachineTypeEnum
public AnimationNodeStateMachine.StateMachineTypeEnum GetStateMachineType();AnimationNodeStateMachine.StateMachineTypeEnumGetTransitionAnimationNodeStateMachineTransition
public AnimationNodeStateMachineTransition GetTransition(int idx);Returns the given transition.
| Name | Type | Default |
|---|---|---|
idx | int | — |
AnimationNodeStateMachineTransitionGetTransitionCountint
public int GetTransitionCount();Returns the number of connections in the graph.
intGetTransitionFromStringName
public StringName GetTransitionFrom(int idx);Returns the given transition's start node.
| Name | Type | Default |
|---|---|---|
idx | int | — |
StringNameGetTransitionToStringName
public StringName GetTransitionTo(int idx);Returns the given transition's end node.
| Name | Type | Default |
|---|---|---|
idx | int | — |
StringNameHasNodebool
public bool HasNode(StringName name);Returns true if the graph contains the given animation node.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
boolHasTransitionbool
public bool HasTransition(StringName from, StringName to);Returns true if there is a transition between the given animation nodes.
| Name | Type | Default |
|---|---|---|
from | StringName | — |
to | StringName | — |
boolIsAllowTransitionToSelfbool
public bool IsAllowTransitionToSelf();boolRemoveNodevoid
public void RemoveNode(StringName name);Deletes the given animation node from the graph.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
RemoveTransitionvoid
public void RemoveTransition(StringName from, StringName to);Deletes the transition between the two specified animation nodes.
| Name | Type | Default |
|---|---|---|
from | StringName | — |
to | StringName | — |
RemoveTransitionByIndexvoid
public void RemoveTransitionByIndex(int idx);Deletes the given transition by index.
| Name | Type | Default |
|---|---|---|
idx | int | — |
RenameNodevoid
public void RenameNode(StringName name, StringName newName);Renames the given animation node.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
newName | StringName | — |
ReplaceNodevoid
public void ReplaceNode(StringName name, AnimationNode node);Replaces the given animation node with a new animation node.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
node | AnimationNode | — |
SetAllowTransitionToSelfvoid
public void SetAllowTransitionToSelf(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetGraphOffsetvoid
public void SetGraphOffset(Vector2 offset);Sets the draw offset of the graph. Used for display in the editor.
| Name | Type | Default |
|---|---|---|
offset | Vector2 | — |
SetNodePositionvoid
public void SetNodePosition(StringName name, Vector2 position);Sets the animation node's coordinates. Used for display in the editor.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
position | Vector2 | — |
SetResetEndsvoid
public void SetResetEnds(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetStateMachineTypevoid
public void SetStateMachineType(AnimationNodeStateMachine.StateMachineTypeEnum stateMachineType);| Name | Type | Default |
|---|---|---|
stateMachineType | AnimationNodeStateMachine.StateMachineTypeEnum | — |
AnimationNodeStateMachine.StateMachineTypeEnum
| Value | Description |
|---|---|
Grouped = 2 | This is a grouped state machine that can be controlled from a parent state machine. It does not work independently. There must be a state machine with |
Nested = 1 | 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. |
Root = 0 | Seeking to the beginning is treated as playing from the start state. Transition to the end state is treated as exiting the state machine. |