Time for action - hook up the explosion
"But wait," you say. How do we actually tell the Script what we want to instantiate? Ah, there's the magic of Unity yet again. Save the Bomb Script, and follow these next steps:
- In the Project panel, select the Bomb Prefab.
- In the Inspector panel, find the Bomb (Script) Component. Notice that the variable we called
prefab is listed there. (If you actually did call your variable "monkeyButt", you'll see that instead.)
- Click and drag the Explosion Prefab from the Project panel into the Prefab variable slot in the Inspector panel. You should see a little red green and blue icon appear in the slot, with the label Explosion Prefab. I've got a good feeling about this!
Test out your game. The bomb falls from the ...