Hey,
Very new to Babylon. Recently learned Blender and animated my own character, which is a cat. There are different animation actions which control different parts of the body (head, main body, tail). I know being new to Blender might mean trouble from there, but I believe I exported everything fine following guides to glb. I made sure that only one animation should have control of a specific bone at a time. Animations don’t have keyframes defined (in Blender) for bones which they don’t control. In Blender, having two simultaneous animations play together in NLA looks as intended.
In Babylon, each animation action is imported as an AnimationGroup. I have read in the docs about Additive animations, animation Blending and Weighted animations. Taking a specific animation for body and head, I did everything I could to have them play together, but only managed to make one of the two play.
Merging the two AnimationGroups into one, enabling Additive animations in merged group.
const mergedGroup = new AnimationGroup(‘MergedAnimationGroup’, this.scene);
for (const targetedAnimation of bodyAnimationGroup.targetedAnimations) {
//targetedAnimation.animation.enableBlending = true;
const animation = targetedAnimation.animation;
// animation.enableBlending = true;
mergedGroup.addTargetedAnimation(animation, targetedAnimation.target);
}
for (const targetedAnimation of tailAnimationGroup.targetedAnimations) {
//targetedAnimation.animation.enableBlending = true;
const animation = targetedAnimation.animation;
// animation.enableBlending = true;
mergedGroup.addTargetedAnimation(animation, targetedAnimation.target);
}
mergedGroup.isAdditive = true;
mergedGroup.start(true, 1, 0, 500, true);
Used both .isAdditive and AnimationGroup.MakeAnimationAdditive()
This will only play only tailAnimationGroup (whichever group is added last to merged).
If, instead of merging, both animation groups are played simultaneously using .play() or .start(), only the last one will take effect, with either tail or main body stuck in default pose mode, depending of which is playing.
If I play an override animation (e.g. body) normally and make the other group additive (e.g. tail), then play, my model will disappear completely.
e.g.
const tailAnimationGroup = AnimationGroup.MakeAnimationAdditive(this.scene.getAnimationGroupByName(‘Idle_Cycle_Tail_Down’))
tailAnimationGroup.play(true);
I have also tried to make a base (override) animation and an additive animation and setting the weight of one or both animations to 1, using:
animGroup.setWeightForAllAnimatables()
as shown in Babylon.js Playground
And syncing one animation with the other using:
tailAnimationGroup.syncAllAnimationsWith(bodyAnimationGroup.animatables[0])
as shown in Babylon.js Playground
From what I understood, blending and weights do not directly concern my use-case, as blending is for interpolating from one animation to another and weights is when two or more animations control the same bones.
In How do you play two AnimationGroups on one skeleton?, I saw this answer: “If your two animation groups target different set of bones, then playing both animations would just work: the first animation group will animate the first set of bones, and the second animation group will animate the second set.”
In my case, only the latter animation to which play() is called has any influence, with the rest of the body taking the default pose. I’m not expecting for something this simple to be hard to do. Does that mean that something is fundamentally wrong with my model/animations or how they were exported?
If I don’t manage to fix this problem, the alternative would be making an animation for every possible combination of (body animation, head animation and tail animation) and that would be far from a nice way to do it. Any recommendations would be very appreciated.
Thanks!