So I have had some time to play with the new version of Unity 3D (version 4) and I decided to play with the new Mecanim animation system and how it works with a NavMeshAgent and a Ragdoll.

For a good starter video tutorial and demo scene on the Mecanim animation system go here:

I decided to see what I could do with the Mecanim animation system, the Navmesh system (Pro version only) and the ragdoll system.

I was very happy to see how easy it is to set up a character with the new Mecanim system. I had a zombie running around my scene in no time at all after watching the about tutorial on the system.

I then created a NavMeshAgent version of the zombie and saved it as a prefab so I could use it later by spawning the zombies on the go.

The video demo below has 200 zombie that are destroyed by explosions and respawner.

I then starting to think it would be nice to change from the Mecanim system to the Ragdoll system when the zombie get hit by the explosion. This turned out to be very easy as well. I just created a ragdoll zombie prefab so I could create it over and over when I needed it.

The zombies have a rigidbody attached to them and a box collider that is use as just a trigger. When the explosion hits the zombie it checks that it is hit by an explosion object (using a tag name) and then if it is an explosion object that has hit the zombie, the zombie object creates a ragdoll version of itself in its current location from the prefab. It then destroys itself and the new ragdoll version of the zombie is affected by the Rigidbody.AddExplosionForce function that the explosion object has on it.

The explosion trigger is just a Physics.Raycast from the camera to the ground and the explosion goes off at the ground hit point.

Here is the first video test of this process: