How to do it...

To create an object-creator GameObject, follow these steps:

  1. Start with a new copy of mini-game Simple2Dgame_SpaceGirl.
  2. In the Project panel, rename GameObject star as pickup.
  3. In the Project panel, create a new folder named Prefabs. Inside this new folder, create three new empty prefabs named star, heart, and key.
  4. Populate the star prefab by dragging GameObject pickup from the Hierarchy panel over star in the Project panel. The prefab should now turn blue and have a copy of all of the star GameObject's properties and components.
  5. Add a new tag Heart in the Inspector. Select GameObject pickup in the Hierarchy panel and assign it the tag Heart. Also, drag from the Project panel (folder Sprites) the healthheart image into the ...

Get Unity 2018 Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.