Animations do not play on Animation Tree Travel

Godot Version

Godot 4.3

Animations do not play on Animation Tree Travel

The problem I am experiencing is that the animations for the 3D model aren’t triggering. The way the project has been set up, a change_anim signal is emitted to signal to other scripts that the animation is changing state, and ideally it should trigger simple code that tells the animation tree to travel to the state.

Sample code to show what I have implemented:

Animation Change Script:

extends Node

@onready var anim_tree = $"../AnimationTree"["parameters/playback"]

func _ready():
	anim_tree.travel("Idle")

func _on_model_change_anim(state: String) -> void:
	anim_tree.travel(state)

Enemy movement script:

signal change_anim(state: String)

func _ready() -> void:
	#Set Idle animation
	change_anim.emit("Idle")

func change_animation(state: String) -> void:
	change_anim.emit(state)

func _on_navigation_agent_3d_target_reached() -> void:
	print_debug("I made it!")
	match Aggression_State:
		Aggression.Aggressive:
			# When they reach the player
			# Grab the new player position
			var player_position = player_target.global_position
			# Check player position, if close enough then you can attack
			if player_position.distance_to(global_position) < attack_margin:
				change_animation("Attack")
			# if not close enough then set new target position
			else:
				Nav_Agent.target_position = player_target.global_position

And here is the state tree for the model.

Everything looks sound. I been following this documentation. Yet the animations are not playing in the scene. So, I am not sure if there is anything I am missing or anything wrong with the logic.

Seems like all your transitions are set to automatically travel, did you set any condition on them? Should some of the transitions away be set to “At end” especially for moving from “Attack” → “Idle” or “run”

Right now, no conditions have been set in the parameters. The transitions shouldn’t be too much of an issue. Unless they prevent animations from playing on travel(). But you do have a point about “At end”. Didn’t catch that until you brought it up, so thanks.

Where would I be able to set conditions in the state tree parameters. Because I saw something about that but not finding it in my editor.

You probably do not want the transitions set to “Auto” if you intend to use .travel often. You could use auto on “Start → Idle” to avoid traveling on _ready.

If you have no condition set then it will automatically travel all the time as soon as possible, likely flickering between states, this behaviour will prevent .travel from being useful. You can set their Condition or use an Advanced Expression when the travel line is selected in the AnimationTree panel. Conditions must be set like other parameters of the AnimationTree, while advanced Expressions can run code automatically.

As it turns out, all of them were set to auto. I thought that they would have by default be set to enabled, but turns out not always. Animations are working now, thank you.