Time for action – Attaching a rag doll

  1. Create a new scene in the project.
  2. Create a ground plane and texture it.
  3. Import the target dummy model into the scene.
    Time for action – Attaching a rag doll
  4. Create a Ragdoll by selecting GameObject | Create Other | Ragdoll…
    Time for action – Attaching a rag doll
  5. Next we need to map the skeleton of our target dummy model to the bone hierarchy of the rag doll. Unity makes this simple by providing a Ragdoll wizard with which we can perform the mapping between the two bone hierarchies.
  6. Select the circle to the right of the Ragdoll item to bring up a list of transforms that you can connect it to.
  7. Drag and drop the soldier (Transform) onto the Root of the item in the list for the Ragdoll nodes that are to be mapped.
    Time for action – Attaching a rag doll
  8. Select the root of the Soldier model in the Hierarchy view so you can see the Ragdoll mapped onto the geometry of the soldier.
    Time for action – Attaching a rag doll
  9. Examine the scene by pressing the Play button.

What just happened?

You will note that the physics system has simulated the various forces on the rag doll and it has collapsed, as gravity is the only force on the dummy and there is nothing preventing it from falling to the ground plane.

This brings up the first problem that we have to solve – we need our model to be rigid until we want it to be impacted by the world of physics. We can accomplish this by either turning off physics until the character is in a state where it should not be in control of its actions, such as in the case of an explosion, or we need to attach the character to some other system that prevents it from slumping over.

We have attached rag dolls and rigid body physics systems to our enemies so that they can animate properly when hit affected by the physics of explosions and other in-world physics simulations. When we turn on the rag dolls, Unity uses physics, as opposed to our animation data, to determine what happens to the character. This results in a more realistic reflection of the world.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.234.114