How do you set a transition node in a blendtree in code with godot4?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BusterDublup

the transition node only has two inputs and starts at 0 at run time but i cant seem to get it to change to the other input in the 1 slot.
I’ve tried:

anim_tree.set("parameters/Transition/transition_request", 1)

and i’ve tried:

anim_tree.set("parameters/Transition/current_state", 1)

but neither seem to do anything. please help.

:bust_in_silhouette: Reply From: zxcdanmn

Here my friend!

# Play child animation connected to “state_2” port.

animation_tree.set("parameters/Transition/transition_request", "state_2")

# Alternative syntax (same result as above).

animation_tree["parameters/Transition/transition_request"] = "state_2"

# Get current state name (read-only).

animation_tree.get("parameters/Transition/current_state")

# Alternative syntax (same result as above).

animation_tree["parameters/Transition/current_state"]

# Get current state index (read-only).

animation_tree.get("parameters/Transition/current_index"))

# Alternative syntax (same result as above).

animation_tree["parameters/Transition/current_index"]
anim_tree.set(transition_request", "state_2")

You can name state_1 0 state_2 1 to use the old way to change