Quick answer: anim_tree.active = true. Get playback via parameter path. Pass exact state node name to travel().
You call travel("run"). Stays on idle. AnimationTree is inactive, or "run" doesn’t match the state node name (case-sensitive).
The Fix
extends CharacterBody2D
@onready var anim_tree: AnimationTree = $AnimationTree
func _ready():
anim_tree.active = true # required
func _physics_process(_d):
var playback = anim_tree["parameters/playback"] as AnimationNodeStateMachinePlayback
if velocity.length() > 10:
playback.travel("Run") # exact node name
else:
playback.travel("Idle")
Active flag turns evaluation on. Parameter path locates the playback. State names are case-sensitive matches against the StateMachine’s node names.
Verifying
Move character. State swaps as expected. AnimationTree visualizer shows current state highlighted.
“Active true. Path right. Names exact. Travel.”
Related Issues
For Skeleton3D bone, see bone modifier. For tween signal, see tween signal.
Active. Path. Name. State changes.