Game Development Reference
In-Depth Information
{
childCollider.enabled = false;
}
}
gameObject.collider.enabled = true;
gameObject.rigidbody.isKinematic = false;
gameObject.GetComponent(Animator).enabled = true;
gameObject.GetComponent(ThirdPersonCharacter).enabled = true;
gameObject.GetComponent(ThirdPersonUserControl).enabled = true;
}
Save the script, return to the Unity editor, save the scene, then playtest. The player character returns
to the top of the ramp anytime you press 1. If the player character was killed, it is reanimated and
ready to go. Awesome—this will definitely speed up playtesting!
Land Mine Zone
All we need for a land mine is the land mine itself and a contact-triggered explosion. The resources
in the Sample Assets will make constructing a land mine quick and simple by using the Ball prefab
for the Land Mines and the Explosion particle effect for the land mine detonation.
In the Project panel, drill down to the Assets ➤ Sample Assets ➤ Vehicles ➤ Rolling Ball ➤ Prefabs
folder and open it. In it you will find a Ball prefab. You could have used Unity's primitive sphere, but
this black ball looks a little more ominous.
Drag a prefab Ball into the Scene view and set its Transform position to (0, 9, 18). In the Hierarchy,
rename it Land Mine. Since the collider is embedded in the track, the physics engine will move the
Land Mine according to this apparent “collision,” which you don't want. With Land Mine still selected
in the Hierarchy, in the Inspector find the Sphere Collider component and check Is Trigger. Next, in
the Rigidbody component, uncheck Use Gravity so the Land Mine will stay put on Play. Immediately
underneath, check the Is Kinematic box. This will prevent surrounding land mines from being
affected by the explosive force of a detonating mine.
Continuing further down in the Inspector, the Ball and the Ball User Control scripts are not needed.
Click the cog icon and select Remove Component in the context menu for each of these script
components (Figure 10-4 ).
 
Search WWH ::




Custom Search