Work in progress
Godot documentation is being updated to reflect the latest changes in version
4.0
. Some documentation pages may
still state outdated information. This banner will tell you if you're reading one of such pages.
The contents of this page are up to date. If you can still find outdated information, please open an issue.
AnimationNodeStateMachine¶
Inherits: AnimationRootNode < AnimationNode < Resource < RefCounted < Object
State machine for control of animations.
Description¶
Contains multiple nodes representing animation states, connected in a graph. Node 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 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");
Tutorials¶
Properties¶
|
Methods¶
void |
add_node ( StringName name, AnimationNode node, Vector2 position=Vector2(0, 0) ) |
void |
add_transition ( StringName from, StringName to, AnimationNodeStateMachineTransition transition ) |
get_graph_offset ( ) const |
|
get_node ( StringName name ) const |
|
get_node_name ( AnimationNode node ) const |
|
get_node_position ( StringName name ) const |
|
get_transition ( int idx ) const |
|
get_transition_count ( ) const |
|
get_transition_from ( int idx ) const |
|
get_transition_to ( int idx ) const |
|
has_node ( StringName name ) const |
|
has_transition ( StringName from, StringName to ) const |
|
void |
remove_node ( StringName name ) |
void |
remove_transition ( StringName from, StringName to ) |
void |
remove_transition_by_index ( int idx ) |
void |
rename_node ( StringName name, StringName new_name ) |
void |
replace_node ( StringName name, AnimationNode node ) |
void |
set_graph_offset ( Vector2 offset ) |
void |
set_node_position ( StringName name, Vector2 position ) |
Property Descriptions¶
bool allow_transition_to_self = false
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.
Method Descriptions¶
void add_node ( StringName name, AnimationNode node, Vector2 position=Vector2(0, 0) )
Adds a new node to the graph. The position
is used for display in the editor.
void add_transition ( StringName from, StringName to, AnimationNodeStateMachineTransition transition )
Adds a transition between the given nodes.
Vector2 get_graph_offset ( ) const
Returns the draw offset of the graph. Used for display in the editor.
AnimationNode get_node ( StringName name ) const
Returns the animation node with the given name.
StringName get_node_name ( AnimationNode node ) const
Returns the given animation node's name.
Vector2 get_node_position ( StringName name ) const
Returns the given node's coordinates. Used for display in the editor.
AnimationNodeStateMachineTransition get_transition ( int idx ) const
Returns the given transition.
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 node.
bool has_transition ( StringName from, StringName to ) const
Returns true
if there is a transition between the given nodes.
void remove_node ( StringName name )
Deletes the given node from the graph.
void remove_transition ( StringName from, StringName to )
Deletes the transition between the two specified nodes.
void remove_transition_by_index ( int idx )
Deletes the given transition by index.
void rename_node ( StringName name, StringName new_name )
Renames the given node.
void replace_node ( StringName name, AnimationNode node )
There is currently no description for this method. Please help us by contributing one!
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 node's coordinates. Used for display in the editor.