How to change AnimationTree's "anim_player" by code

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

Whenever I try to change the Animation Tree’s “Animation Player” with the line:

$AnimationTree.anim_player = NodePath("../"+weaponName+"Animation/"+weaponName+"AnimationPlayer")

The Debugger is spammed with the error:

E 0:00:09.137 _process_graph: Condition “!track_cache.has(path)” is
true. Continuing. <C++ Source> scene/animation/animation_tree.cpp:861
@ _process_graph()

Do I need to do something like stop it’s current animation to be able to change it?

:bust_in_silhouette: Reply From: overlord666

set two variables and the set the animation tree = to animation player