Applying Ragdoll physics to a character
Action games often make use of Ragdoll physics to simulate the character's body reaction to being unconsciously under the effect of a hit or explosion. In this recipe, we will learn how to set up and activate Ragdoll physics to our character whenever she steps in a landmine object. We will also use the opportunity to reset the character's position and animations a number of seconds after that event has occurred.
Getting ready
For this recipe, we have prepared a Unity Package named Ragdoll
, containing a basic scene that features an animated character and two prefabs, already placed into the scene, named Landmine and Spawnpoint. The package can be found inside the 1362_07_08
folder.
How to do it...
To apply Ragdoll physics to your character, follow these steps:
Create a new project and import the
Ragdoll
Unity Package. Then, from the Project view, open the mecanimPlayground level.You will see the animated MsLaser character and two discs: Landmine and Spawnpoint...