O'Reilly logo

Unity 3D Game Development by Example by Ryan Henson Creighton

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

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:

  1. In the Project panel, select the Bomb Prefab.
  2. 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.)
  3. 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 ...

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