Class reference
AnimationNodeStateMachinePlayback
Inherits Resource
Provides playback control for an AnimationNodeStateMachine.
Description
Allows control of AnimationTree state machines created with AnimationNodeStateMachine. Retrieve with $AnimationTree.get("parameters/playback").
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 resource_local_to_scene = true
bool resource_local_to_scene = trueMethods
float get_current_length() const
float get_current_length() constReturns the current state length. Note: It is possible that any AnimationRootNode can be nodes as well as animations. This means that there can be multiple animations within a single state. Which animation length has priority depends on the nodes connected inside it. Also, if a transition does not reset, the remaining length at that point will be returned.
StringName get_current_node() const
StringName get_current_node() constReturns the currently playing animation state. Note: When using a cross-fade, the current state changes to the next state immediately after the cross-fade begins.
float get_current_play_position() const
float get_current_play_position() constReturns the playback position within the current animation state.
StringName get_fading_from_node() const
StringName get_fading_from_node() constReturns the starting state of currently fading animation.
StringName[] get_travel_path() const
Returns the current travel path as computed internally by the A* algorithm.
bool is_playing() const
bool is_playing() constReturns true if an animation is playing.
void next()
If there is a next path by travel or auto advance, immediately transitions from the current state to the next state.
void start(StringName node, bool reset = true)
StringName node, bool reset = true)Starts playing the given animation. If reset is true, the animation is played from the beginning.
void stop()
Stops the currently playing animation.
void travel(StringName to_node, bool reset_on_teleport = true)
StringName to_node, bool reset_on_teleport = true)Transitions from the current state to another one, following the shortest path. If the path does not connect from the current state, the animation will play after the state teleports. If reset_on_teleport is true, the animation is played from the beginning when the travel cause a teleportation.
Signals
state_finished(StringName state)
StringName state)Emitted when the state finishes playback. If state is a state machine set to grouped mode, its signals are passed through with its name prefixed. If there is a crossfade, this will be fired when the influence of the get_fading_from_node() animation is no longer present.
state_started(StringName state)
StringName state)Emitted when the state starts playback. If state is a state machine set to grouped mode, its signals are passed through with its name prefixed.