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:
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.
Rename the Prefab
Bomb
. Just like Spark Material, the icon helps us to keep track of what type of thing it is. For further clarity, consider adding the Bomb Prefab to a new folder, which you should callPrefabs
.In the Hierarchy panel, click-and-drag the Sparks Particle System to the Bomb GameObject.
In the...