Game Development Reference
In-Depth Information
Step 4. Delete Main Camera from the Hierarchy. There is already
a camera attached to the FPC and the Main Camera is no longer
needed.
Step 5. Play. The FPC will fall straight through the floor. Why? The
warehouse mesh does not have any colliders and therefore there is
nothing to stop the FPC falling. Each surface of the mesh requires a
mesh collider to be added.
Step 6. In the Hierarchy, select wareHouseFBX and expand it by
clicking on the small triangle to the left of its name. This model is
made up of a number of meshes. They are called polySurface88,
polySurface89, and so on. Select polySurface88, scroll to the
bottom of the list, and SHIFT select polySurface 1518. With all the
surfaces selected, go to the main menu and select Component
> Physics > Mesh Collider. Each surface will have a mesh collider
added to it using its own mesh shape. Quickly scan through the
polySurface meshes individually and note the new Mesh Collider
component added and that the Mesh property of this is set to its
own mesh.
Step 7. Play. The FPC will fall and hit the floor. You will be able to
move around with the arrow or WASD keys and jump with the
spacebar. If the FPC falls through the floor it will be because it either
starts slightly merged with the floor or the floor does not have a
mesh collider. Move the FPC up a little and check the floor mesh for
a collider and try again.
Step 8. As you try and move around, you will find that the stairs pose
a little challenge. To adjust the settings of the FPC to handle these,
select the FPC in the Hierarchy and locate the Character Controller
component in the Inspector. Change the value of Slope Limit to 80
and the Step Offset to 0.1. This will allow the FPC to go up slopes
with up to an 80° incline and to move up stairs with a height of 0.1.
Although the stairs are 90° for each vertical face, the small upward
bounce the FPC experiences when it hits the stairs is enough to
push it up to the next one with the Slope Limit set to 80. Try walking
around with these new settings.
Step 9. Create a Sphere. Set its scale to (0.5,0.5,0.5) and position
it at (0,0,0).
Step 10. Add a Rigidbody to the Sphere by selecting it in the
Hierarchy and choosing Component > Physics > Rigidbody from
the main menu.
Step 11. Create a JavaScript file and call it blob . Leave it empty.
Step 12. Attach blob.js to the Sphere.
Step 13. In Project, create a Prefab and call it bullet . Drag and
drop Sphere from the Hierarchy and drop it onto the bullet
prefab. Check that the prefab now has the properties of Sphere,
including the blob.js script attached. Delete Sphere from the
Hierarchy.
Search Nedrilad ::




Custom Search