How it works...

This recipe simply applies a force to a chosen body part of the ragdoll using the AddForce() function called on the limb's Rigidbody component. This function requires a Vector3 force parameter that describes the direction and magnitude of the applied force. We can also specify a ForceMode mode parameter to change the mode of the applied force. Here we've chosen to use the ForceMode.Impulse as our force is applied only in one frame.

The rest of the script handles selecting the body part we want to apply the force to. In this example, we are using the mouse input to cast a ray and try to hit a body part's collider. If we manage to do so, we choose this particular limb as the target that we want to apply the force to.

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

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