O'Reilly logo

Getting Started with Unity by Patrick Felicia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Collecting objects

So far, we have managed to implement navigation around the maze as well as a timer. As we initially planned, we will now need to make it possible for the player to collect objects (for example, med packs and keys) to escape the maze. To collect the objects, we will use collision detection and a script that will destroy the objects collected. First, let's create some items and add them to the scene:

  1. Create a new cube, rename it medpack, then change its position to (x=3, y=1, z=6), and its scale to (x=0.5, y=0.5, z=0.2).
  2. Locate the texture labeled texture_medpack in the folder Assets | chapter3 | chapter3_pack. Apply the texture texture_medpack to the cube.
  3. Create a new script inside the folder chapter3 | Scripts and rename it

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required