Time for action – prefabulous

Our game is going to contain not one bomb, but many. As with programming, doing something more than once in Unity completely stinks, so we're going to take a shortcut. We're going to create a built-in thing called a Prefab that will let us create a reusable bomb, much the same way we created a programmatic function that we could call multiple times in our script.

Follow these steps to create your first Prefab:

  1. Right-click/secondary-click on the Project panel and navigate to Create | Prefab, or navigate to Assets | Create | Prefab in the menu. A gray box icon appears in your Project panel, labeled New Prefab. Because the box is gray, we know this Prefab is empty.
  2. Rename the Prefab Bomb. Just like Spark Material, the icon ...

Get Unity 4.x Game Development by Example Beginner's Guide 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.