Game Development Reference
In-Depth Information
Fig 4.12 Positioning a box collider
around an existing mesh.
Step 3. Drag and drop the cone from the Hierarchy onto the cone
prefab in the Project to replace it with a new copy that includes a
collider. Remove the existing cone from the Hierarchy.
Step 4. Using the new cone prefab, add several cones into the Scene
on the road in front of the car.
Step 5. Play. Try to run over the cones. They won't budge because
they do not have a rigidbody attached.
Step 6. Because all the new cones are linked to the prefab, to add
rigidbodies to them all, just add a single rigidbody to the cone prefab
in the Project. Select it and then Components > Physics > Rigidbody
from the main menu.
Step 7. Play. The cones will now move out of the road when hit with
the car. If your cones seem to fall through the ground, check that their
starting position in the scene has the rigidbody above the terrain. If
there is any overlap, gravity will cause the cones to fall through the
Step 8. Create a prefab call Duck , attach the RubberDucky model,
and then add a rigidbody and a box collider. Add the Duck prefab
to the scene.
Step 9. Create a new cube. Make it about twice the size of the car
and position it behind the car. Embed it in the ground so that only
a small part of the top appears out. It should be low enough to
drive the car up onto. Offset the box collider so that it is above
the ground, as shown in Figure 4.13 . Tick the Is Trigger box
for the collider.
Search Nedrilad ::

Custom Search