Up to date

This page is up to date for Godot 4.1. If you still find outdated information, please open an issue.

AnimationNodeTransition

Inherits: AnimationNodeSync < AnimationNode < Resource < RefCounted < Object

A transition within an AnimationTree connecting two AnimationNodes.

Description

Simple state machine for cases which don’t require a more advanced AnimationNodeStateMachine. Animations can be connected to the inputs and transition times can be specified.

After setting the request and changing the animation playback, the transition node automatically clears the request on the next process frame by setting its transition_request value to empty.

Note: When using a cross-fade, current_state and current_index change to the next state immediately after the cross-fade begins.

GDScriptC#

  1. # Play child animation connected to "state_2" port.
  2. animation_tree.set("parameters/Transition/transition_request", "state_2")
  3. # Alternative syntax (same result as above).
  4. animation_tree["parameters/Transition/transition_request"] = "state_2"
  5. # Get current state name (read-only).
  6. animation_tree.get("parameters/Transition/current_state")
  7. # Alternative syntax (same result as above).
  8. animation_tree["parameters/Transition/current_state"]
  9. # Get current state index (read-only).
  10. animation_tree.get("parameters/Transition/current_index")
  11. # Alternative syntax (same result as above).
  12. animation_tree["parameters/Transition/current_index"]
  1. // Play child animation connected to "state_2" port.
  2. animationTree.Set("parameters/Transition/transition_request", "state_2");
  3. // Get current state name (read-only).
  4. animationTree.Get("parameters/Transition/current_state");
  5. // Get current state index (read-only).
  6. animationTree.Get("parameters/Transition/current_index");

Tutorials

Properties

bool

allow_transition_to_self

false

int

input_count

0

Curve

xfade_curve

float

xfade_time

0.0

Methods

bool

is_input_reset ( int input ) const

bool

is_input_set_as_auto_advance ( int input ) const

void

set_input_as_auto_advance ( int input, bool enable )

void

set_input_reset ( int input, bool enable )


Property Descriptions

bool allow_transition_to_self = false

  • void set_allow_transition_to_self ( bool value )

  • bool is_allow_transition_to_self ( )

If true, allows transition to the self state. When the reset option is enabled in input, the animation is restarted. If false, nothing happens on the transition to the self state.


int input_count = 0

  • void set_input_count ( int value )

  • int get_input_count ( )

The number of enabled input ports for this animation node.


Curve xfade_curve

  • void set_xfade_curve ( Curve value )

  • Curve get_xfade_curve ( )

Determines how cross-fading between animations is eased. If empty, the transition will be linear.


float xfade_time = 0.0

  • void set_xfade_time ( float value )

  • float get_xfade_time ( )

Cross-fading time (in seconds) between each animation connected to the inputs.


Method Descriptions

bool is_input_reset ( int input ) const

Returns whether the animation restarts when the animation transitions from the other animation.


bool is_input_set_as_auto_advance ( int input ) const

Returns true if auto-advance is enabled for the given input index.


void set_input_as_auto_advance ( int input, bool enable )

Enables or disables auto-advance for the given input index. If enabled, state changes to the next input after playing the animation once. If enabled for the last input state, it loops to the first.


void set_input_reset ( int input, bool enable )

If true, the destination animation is restarted when the animation transitions.