Active ragdoll physics

Has anybody had any experience with creating active ragdolls in Babylon?

For example when you run, but a box hits you from above, the head reacts to the box while still trying to keep the animation going?

1 Like

cc @Cedric

I didn’t try but I’m curious to see how people have managed to do it :slight_smile:

I’m also interested in this. I found this article http://peyman-mass.blogspot.com/2018/01/how-to-implement-active-ragdoll.html?m=1

It mentions this, and I quote:

Physically based animation is also known as active ragdoll or animation driven ragdoll and if you have used Havok animation before, it’s called powered ragdoll in Havok animation.

Which makes me wonder, now that Babylonjs can use havok as a physics engine, does this mean that we also have access to this so called “powered ragdoll”?

1 Like

Havok wasm build doesnt contain everything possible. We cherry pick what’s needed or the wasm would be multiple Mb. Ragdoll is not used by everyone so, it’s preferable to have our own version based on user feedback.

I see that this playground https://playground.babylonjs.com/#DLPNQT#6 has an animation group that keeps playing even after the ragdoll is turned on. I’m guessing the animation is ignored because the physics are taking precedence. Is there a way that I can extract the current animation frame values for each bone and convert them to the appropriate physics force in order to blend the ragdoll back into the animation shape over time?

In playing around in the js console I see I can get what frame the animation is on using:

scene.animationGroups[0].animatables[30].masterFrame

But I haven’t figured out how to see what value the frame is supposed to be at.

1 Like

Once you have a frame number, you can get the value of an animation by calling Animation.evaluate(frame). For a given animation group, you can get the list of all animations by calling AnimationGroup.targetedAnimations.

LOL looks like a zombie trying to stand up…

https://playground.babylonjs.com/#DLPNQT#12

first click on “Ragdoll on”, then click on “Impulse” to see my attempt at making active ragdoll.

My thinking here was:

  1. There are 69 bones in the skeleton
  2. There are 13 physics bodies in the ragdoll (so right away there is a mismatch between the ragdoll parts and the skeleton animation… but let’s try anyway!)
  3. As the animation plays get the frame number, loop through each of the physics bodies, find a corresponding bone and get its supposed animation value at that time frame. Calculate the difference between the animation target value and the ragdoll transform node value and apply a small impulse to drive the transformNode/physicsBody in the direction of the animation.

Based on the console logs though, the target animation values and the ragdoll transformNode values don’t seem to be in the same coordinate space. Even before ragdoll is turned on, these two values are very different. So I think the impulse applied is pretty non-sensical. I’m not sure. I’m out of my depth here.

Any ideas?

1 Like

Angular impulse takes a vector (a torque force) and not Euler angles