Game Development Reference
In-Depth Information
Classified intel
In this section, we have used the robotAI_ragdoll prefab and added it to the scene when
our AI gets destroyed. The concept of this section is that we have to separate the ragdoll
from the AI object. Then, we add the ragdoll and destroy the AI object. Of course, this is
just one way to create the ragdoll effect for the character. The advantage of separating them
is that we don't need to worry about the ragdoll object when we need to update the char-
acter. We can have the ragdoll already set up and just work on the update of character's an-
imation. This will prevent us from making an error when we change something in the
script.
On the other hand, this method isn't that good if we need an accurate collider for each part
of the character's body. In this case, we can also have the ragdoll and character animation in
the same game object by attaching the Animator component to control the animation.
Then, we can use Is Kinematic in Rigidbody to enable or disable the ragdoll physics to
use the ragdoll mode or character animation.
When we added the ragdoll prefab to the scene, we also added force using the Ad-
dForce() function to our ragdoll's rigidbody. This makes our ragdoll object move fol-
lowing the rocket's direction. We set the force mode to ForceMode.VelocityChange
to change the velocity as soon as the rocket hits the character by ignoring its mass. This
way we can make sure that we have the same velocity applied to all the parts of our rag-
doll object.
Note
For more information on ForceMode.VelocityChange , visit the following URL:
http://docs.unity3d.com/Documentation/ScriptReference/ForceMode.VelocityChange.html
Search WWH ::




Custom Search