Proper/optimized way to ragdoll an animated character

Hi everyone,

I’m developing a VR FPS game on Windows that will need the use of ragdolls for death.

For now, I used the built-in wizzard to create ragdolls for my animated characters. When the character dies, I disable the animator, switch the rigidbodies from kinematic to non-kinematic, and enable their collision detection. The problem is that there is no way to disable completely the rigidbodies.

Unity documentation advices to proceed the way I did. The problem is that when the character is not ragdolized, rigidbodies create massive overhead on Physics and scripts when they are moved by the scripts and by the animator.

Is there a better way to “disable” Rigidbodies?

I’ve tried pooling a second character as ragdoll and replacing on death, the issue is that it seem to glitch with physics and the ragdoll has weird behaviour, probably due to the fact that I update all transforms at once on death to make it match the previous character’s animation.

Do you have other solutions?

Thank you for your help!

Have you tried to remove the Rigidbody component?

Destroy(Object.GetComponent<Rigidbody>());

Hi, thank you for your answer!

This won’t work because it will break the joints relationships between the limbs of my ragdoll

I have still not found an answer to my issue.

I’m very surprised because ragdolls seems to be a common practice in most games today, and the “default” way (switching from kinematic to non kinematic) seems to perform very bad due to heavy unnecessary continuous computations.

Removing rigidbody is also pretty unpredictable, I think it’s because it sometimes involve weird recomputations of what unity consider to be the “static collision world”.

Not having colliders is not an option for a shooter, but those colliders are just used for raycasting, no actual mesh to mesh collisions. But apparently there is no way to disable mesh/primitive intersection computations in Unity.

So my question is:

What is the standard clean and well performing way to implement animation to ragdoll for FPS in Unity?

Isn’t there at all a way to involve all these heavy unnecessary computations?

Please, I need help…

You can also raycast triggers, not sure if its the solution, just putting it out there

Thank you for your answer, but setting colliders as triggers doesn’t seem to change anything on “overlap” computations…

put kinematic colliders on separate layer to minimize performance impact

1 Like

No, I tried, layers don’t seem to avoid computations, they only avoid “physics behaviours” computations. the only thing that seem to work is to disable colliders when not raycasting. but it results in CPU spikes and seems too dirty to be the “right way” to do it.

I’m pretty sure I’m missing something simple, I can’t believe there would be no way for Unity to do character hitboxes/ragdolls without all these unnecessary computations.

Please, help!

I have the same problem :-(. Does anybody know how to solve this problem?

It’s not really the kinematic rigidbodies that are causing the overhead it’s the joints. The joints cannot be turned off and a lot of them can be a drain n the physics engine.

that’s said, I’m still looking for the best way to do it myself. I spawn in ragdolls for my characters, but it’s not perfect.

I currently have problems with getting the exact velocity for each limb to be transferred properly.

How about using LOD, or another criteria to switch between a ragdoll model, and a simplified animated version?