简体   繁体   中英

How to play multiple animations at once?

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?

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.

AnimationNodeBlendTree 设置

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM