Dynamic loading and deloading animations in animation tree

Godot Version

4.6-rc2_mono , godot 4

Question

I’m trying to make a game where the moveset of a character is dependent on the equipment.

I need:

  • to blend walking animations through a blend space
  • to blend upper body and lower body animations together.
  • to have a default blend between any upper body and lower body animations.

So naturally I chose to use an Animation Tree.

I initially started working with AnimationTree state machine nodes but the lack of “any state” node made it impossible to realistically have default blending between animations.

I moved on to input all my animations and blendspaces onto a Transition node in a blend tree so that I’d have the ability to blend everything smoothly. The Upper body transition and lower body transition are then going into a blend2. It works nicely.

Now comes the problem of the movesets that are dynamic. I can naïvely just put the entirety of all animations in there and input them in the transitions. But it isn’t neat.

So what I’ve done is every piece of equipment has their own AnimationPlayer, AnimationLibrary and AnimationTree. I’d list the animations in a script, and I have equip/unequip function that load the AnimationLibrary on the character animation tree, copy pastes the animations in the blend tree, and connects them to the Transition nodes.

It works. But it seems like a mouthful. I would like to know if someone knows a better or simpler way to do this. Or if there’s a feature that exists or is planned that could be of interest.

Thank you for reading!