Game Development Reference
In-Depth Information
Step 8. Move each of the beakers so that they make a line across the
bottom of the camera's view as shown in Figure 4.2 .
Fig 4.2 The initial setup for a
matching and sorting game.
Step 9. Add a cube to the scene. Position it at (0,2,0) and give it a scale
of (20,0.2,1) as shown in Figure 4.3 . Tick the Is Trigger box of the Box
Collider and set the z size to 10. The cube will appear as a white strip
across the game with a large box collider. Ticking the Is Trigger box for
the Box Collider will enable triggering an event when another object
collides with it; however, it will not cause any physics events. This will
allow objects to fall through it, but we can detect when this is happening
Step 10. Create a sphere. Position it at (0,0,0) and scale it to
(0.5,0.5,0.5). Attach a Rigidbody and set the drag to 10. In the
Rigidbody settings for Constraints, tick the Z value of Freeze Position.
This will keep the sphere always at its initial z value (in this case 0)
even after a physics event.
Step 11. Turn the sphere into a prefab object called ball. Delete the
original sphere object from the Hierarchy.
Step 12. Create a new JavaScript file called destroyWhenGone.js . Enter
the code shown in Listing 4.1 .
Search Nedrilad ::

Custom Search