Full ragdoll blending + stability

I have been having, fun - if you will, trying to get a stable ragdoll that gets thrown to the ground and gets up using a form of canned animation.

Through my ventures, I have found that modifying USkeletalMeshComponent::BlendPhysicsBones to be a solution - ensure that when blending the first bone with a physics body (most likely the root) to set UsePhysWeight to 1.f. Without this, all the physics bodies that I made would get a rotational force on their root bone from the blending which kept on accumulating and spinning ever faster.

Within game code, I’ve tried to set the blending to 1. for the root node, and less for the child nodes to interesting results (ie - numerical explosions).

At the moment, I prefer the modification to the engine since it is a 4-5 lines of code and removes the need for special casing for the root node. All that I must do is ensure that the physics body doesn’t move in zero gravity.

To see the instability, you can open the ContentExample’s ragdoll, and set the “Physics Blend” to something like 0.2. If you do the above changes, the ragdoll is much more stable (iff it doesn’t move in zero G!).

However, and the question of this post, is there something I missing such that I don’t have to modify the engine and still get stable ragdolls that blend back to an animation without having to do any special casing for the root physics bone in game-code?


So, one has to modify unreal source, or only edit something in c++ using stock editor? I have the same problem with character spinning out of control.
Would You post detailed information how did you managed to stabilize it?

This is something I’d like to know about too; it would be really sweet to make “animated ragdolls” in the vanilla version of the engine.

Epic should add the change to the engine as a checkbox…

I made the change to line 244 in Engine\Source\Runtime\Engine\Private\PhysicsEngine\PhysAnim.cpp (which is currently):

                float UsePhysWeight = (bBlendPhysics) ? 1.f : BodyInstance->PhysicsBlendWeight;

I changed it to:

                float UsePhysWeight = (bBlendPhysics || BodyIndex == 0) ? 1.f : BodyInstance->PhysicsBlendWeight;

Which (I think) should take the root bone and set its PhysWeight to 1 (meaning it’s fully physicalized).

Collisions between animated limbs and the environment aren’t very stable yet (setting a guy going with a walk animation and a “keep upright constraint” leads to the feet clipping through the ground and general jitteryness…), but it’s much better than before the change.

i’ve just posted a video asking this excact same question just for blueprints i guess (since that’s all i know). I even tried to first set “Set All Bodies Below Physics Blend Weight” = 1 for Root and then to 0.5 for the “Pelvis”, still he’s spinning like crazy.

Oh and the video is here (to compare results):

Wow, amazing contrib!

I wonder if you would just create some kind of interface or neat compositional functionality in order to work around this in game code only?

Something like a strategy pattern might bring this kind of functionality in nice and easily and allow it to be dynamic at runtime.

At the end of the day, all you’re trying to do is assert that the root joint’s PhysicsBlendWeight is set to 1.

I think design pattern your way around that and it might sit cleanly in game code?

Unless, does it not work at all in game code?

I am about to give it a shot in the engine (compiling, yay!)

I managed to get something like this working without altering the engine. It took quite a bit of experimenting and headscratching, and i havent yet made excactly what i wanted, but something looking very promising. Take a look at this tutorial thread i made in order to share my findings. Hope it will prove usefull, and let me know how to improve this.

This doesn’t seem to have helped.

Surely this issue must be resolved another way by now?