Introduction to Ragdoll

Simon Pham
4 min readAug 8, 2024

--

In today’s blog post, let’s discuss ragdoll physics in Unity.

What are ragdoll physics?

Ragdoll physics are a set of colliders, rigid bodies, and joints applied to a humanoid character to simulate effects like impact collisions and character deaths.

Overwatch 2

Demonstration

Scene setup

For this demo, I’ve created a scene with a fireman model in mid-air.

Fireman model

This model has two parts: a mesh and a skeleton that represents the transform positions of its bones.

If I expand the skeleton hierarchy a little bit more, you’ll notice that it has a lot of bones; however, we only need the major bones in a ragdoll physics simulation.

Creating ragdoll

To create a ragdoll, I’m going to right-click on the parent object and select 3D Object > Ragdoll.

This will open up a new window called Create Ragdoll.

Now, we need to assign the bones to their correct slots in this window. When working with a rigged skeleton, the most important bone is the root bone, which is usually referred to as the pelvis or hips in some cases. I’m going to drag and drop the hips bone (mixamorig_Hips) into the Pelvis slot.

The next slot that we need to find a corresponding bone for is the Left Hips. Sometimes, the name of a bone might not match what we’re looking for, and that’s when we need to locate it on the model.

When I click on the mixamorig_LeftUpLeg bone in the Hierarchy window, I notice that it is at the hip level.

mixamorig_LeftUpLeg bone

So we can use this for the Left Hips slot.

Similarly, I’ll assign the mixamorig_LeftLeg bone to the Left Knee slot since it seems to be located at the knee position.

mixamorig_LeftLeg bone

Next, the mixamorig_LeftFoot bone can be assigned to the Left Foot slot since their names match.

I’ll do the same for the other bones. Also, I’ll leave the Total Mass, Strength, and Flip Forward properties as they are and click Create.

Before we test this out, I noticed that the sphere collider on the head is little bit off so I’m going to adjust it.

You can do that by selecting the head in the Hierarchy, clicking on the Edit Collider button in its collider component, and using the handles to adjust its size and position.

And here’s the result in Play mode.

Enhancing ragdoll physics simulation

You might have noticed that the character’s feet sink through the ground and are left out of the ragdoll physics.

Feet are left out from ragdoll physics

To fix this issue, I’m going to set up some extra joints and colliders.

Let’s start with the right foot. I’m going to add a Capsule Collider component, and it doesn’t have to be positioned perfectly.

Next, I’m going to add a Character Joint component, which will then automatically add a Rigidbody component to the GameObject. After that, I’m going to assign the right leg bone (mixamorig_RightLeg) to the Connected Body field in the Character Joint component.

We can repeat the process for the left foot. And here’s the result:

You can see that the feet no longer sink through the ground and they look much more natural.

--

--