How to play two conflicting animations at the same time?

Godot Version

4.5.1

Question

I have a 2d character, consisting of 5 different sprite 2d nodes rotating independently for my animations. Head, Body/Torso, 2 legs and 2 arms.

I have a walk animation that moves both arms and legs at the same time.
I have an idle animation that resets everything to original rotations and a hit animation that moves his arms only.

I want to allow continuing walk animation while hitting.

The issue is that no solution I’ve have tried so far, didn’t work.

From multiple animation trees to blend 2 and one shot state machine nodes, with static or dynamically changing blending values, all broke a part of one state’s animation.

Most answers I find online, have two animations moving different body parts play the same time but not two animations moving the same parts.

Did anyone manage to do such a thing? If yes, could you tell me how to do it too?
Thanks.

So first, your 2D character needs to have a Skeleton2D and use Inverse Kinematics animations. Then, use an AnimationTree with a Tree Root that is an AnimationNodeBlendTree. Add a Blend2 node, with your two animations as inputs. Press the Edit Filters button. You’ll get something like this:

Check the Enable Filtering checkbox, and the parts of the animation you want blended.

Specifically, you want the walk animation as the in, and then you want to blend the top half of the animation with the attack animation at full strength.

Thanks for your response!

To implement your solution I also had to learn how skeletons and bones work in Godot and then manually set blend mode to 1 or 0 in my code to allow hit to override arm movement but only while hitting.

But now everything finally works! Thanks again.

1 Like