Game Development Reference
In-Depth Information
Figure 7-13. Original Capsule Collider (left) and Ragdoll colliders (right)
In the Hierarchy, select each of the child body parts used for the Ragdoll Wizard in turn and uncheck
to disable the Collider components in the Inspector, and for each of the new Rigidbody components
check the Is Kinematic box. Leave the parent Third Person Character Ragdoll Rigidbody and
Capsule Collider components enabled. The player character functions normally in Play mode again.
To go from normal player-controlled animations and movement to a physics-engine-driven ragdoll
state requires a script. In the Project panel's Assets ➤ Scripts folder, select Create ➤ Javascript and
name the new script GoRagdoll. Add the following code:
#pragma strict
private var childRigidBodies : Rigidbody[];
private var childColliders : Collider[];
function Start ()
{
childRigidBodies = gameObject.GetComponentsInChildren.<Rigidbody>();
childColliders = gameObject.GetComponentsInChildren.<Collider>();
}
function GotoRagdoll ()
{
if (childRigidBodies != null)
{
for (var childRigidBody : Rigidbody in childRigidBodies)
{
childRigidBody.isKinematic = false;
}
}
 
Search WWH ::




Custom Search