Reputation: 1968
I'm trying to play 2 animations at once
for example,
my arms have the animations: static
, running_swing
& drawing weapon
my legs have the animations: static
, running
and I want to play them both, simultaneously in any combination like:
arms running_swing
& legs running
or
arms drawing weapon
& legs running
so far the only way I found was to create 2 separate AnimationPlayer
s
and play them one after the other:
$AnimationPlayerArms.play("running_swing");
$AnimationPlayerLegs.play("running"); # but this approach too isn't simultaneous
or use Tween
but that approach also fails because it becomes really difficult the more the animations are complicated
So is there any way or method that I might be missing?
Upvotes: 2
Views: 10023
Reputation: 40355
You can use an AnimationTree
.
As usual, set the AnimationPlayer
, and set active
to true.
For the tree_root
set new AnimationNodeBlendTree
. Then make an Animation node for each of your animations. Connected them together via Blend nodes (I'd use 0.5
for the blend value). And I'll add a Seek node at the end to control it.
The AnimationTree
would have added parameters for the blend values and the seek value. Setting the seek parameter to 0 will restart both animation.
As long as the animation do not set the same variable, you have the desired effect: both animation play. If the animations set the same variable, you get an interpolation between the two, controlled by the blend value.
Upvotes: 3