So, what's a ragdoll? A ragdoll "is a children's toy. It is a cloth figure, a doll traditionally home-made from (and stuffed with) spare scraps of material" and the same approach is used in video games.
Unity has a simple wizard that lets you quickly create your own ragdoll. You simply have to drag the different limbs on the respective properties in the wizard. Then select create and Unity will automatically generate all Colliders, Rigidbodies and Joints that make up the Ragdoll for you. (something you need to know / guess, as a ragdoll is basically a collection of rigibodies it will be affected by physics, gravity and forces)
Here you have a Unity 3D Ragdoll Easy Tutorial (this all you need to know to make a ragdoll)
This is really easy, but what if the character have any other logic or components like animators, rigidbody, script, etc?
Let's take a look at Ethan from Unity3d Project #01: Stealth. Ethan has a lot of components attached to him.
If I just add the ragdoll to Ethan, It'll be a completly mess (I've already did it, try it by yourself), so what can we do? These are the step I follow (guided by some answers I found on the Internet):
- Create a ragdoll to Ethan
- Disable all child (ragdoll) rigidbodies (script AnimatorToRagdoll.cs)
- When Ethan dies, destroy / disable main components (With a mouse click, Ethan dies)
- Eneable all child (ragdoll) rigidbodies
The result is here http://bit.ly/17pl47F With a mouse click, Ethan dies
You can download the full project here: http://bit.ly/1dYsO1I