Changing animations in Animation Tree via script

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

I have an Animation Tree set up with a State Machine tree root and BlendSpace2D and (single) Animation nodes inside. (see image)

I’d like to change what animation the ‘custom_anim’ nodes should play via script, but can’t figure out how to do it, if possible.

For example I can change the blend position of the ‘walk_blend’ node like this:

animation_tree["parameters/walk_blend/blend_position"].x = direction.x

Based on that I tried these, but they don’t work:

animation_tree["parameters/custom_anim_1/animation"] = "some_animation"   

Is it possible to set the animations for these nodes via script? Thank you in advance!

:bust_in_silhouette: Reply From: Monday

I figured it out, this is how you get nodes and their properties inside the animation tree, in case someone else don’t know:

animation_tree.get_tree_root().get_node("custom_anim_1").animation = "some_animation"