Applying force to a ragdoll
In this recipe, we are going to apply some additional force to a ragdoll when we turn it on. Normally, when you turn the ragdoll on, it starts from idle; no initial movement is introduced. It looks stiff and unnatural. Applying force to a body part will help to avoid that.
Getting ready
We are going to use the same character as in the Creating a humanoid ragdoll with the ragdoll wizard recipe. We will also use the HandleRagdoll.cs
script from the same recipe to turn the ragdoll on. You can also open the example Unity project and go to the Chapter 09 Physics and animations\Recipe 06 Applying force to a ragdoll
directory. If you open the Example.unity
scene there and play the game, you will be able to click on any body part of the character. That will turn the ragdoll on and apply force to this body part, which will make the character look like it was hit or shot in that particular limb:
Force applied directly to the head of the character
How to do it...
To apply force...