AnimationTree with changing AnimationPlayer?

Godot Version

4.4

Question

I have 3 characters with the same skeleton and the same animations that I want to turn into a random looking enemy. Essentially, I want a CharacterBody3D with the 3 Skeletons (each with their own AnimationPlayer) and then have a single AnimationTree that gets one of the AnimationPlayers assigned via GDScript.

But assigning an AnimationPlayer to an AnimationTree doesn’t seem to do anything. Just to create the animation system I assigned one of the AnimationPlayer nodes to the AnimationTree and then added:

func _ready() -> void:
	$AnimationTree.anim_player = "CharacterB/AnimationPlayer"

But that didn’t do anything: To create the animations I assigned the AnimationPlayer from CharacterA to the AnimationTree and that’s where it stayed despite the code in the ready function. I also checked the AnimationTree node at runtime and it has assigned CharacterB/AnimationPlayer to the AnimationTree but in the game only CharacterA is animated.

Am I doing something wrong here? I am a bit paranoid about the string to the AnimationPlayer because it feels weird but Godot throws an error when I add the node itself.

Nevermind, I am stupid! The problem was that the path to the AnimationPlayer node needs to start from the AnimationTree and not from the root node (or wherever the code is run from).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.