Time for action – the point of impact

We're finished tweaking the explosion, so you should delete the instance of the Explosion Prefab from the Scene view. The original stays safe and sound in the Prefab container in your Project panel. Naturally, we want this explosion to appear whenever we detect that the bomb has hit the ground. We've already put the logic in place to detect a ground hit—remember that we're moving the bomb back up into the sky as soon as it drops below ground level. So it should be a reasonable hop, skip, and jump towards making that explosion happen. And luckily, it is!

  1. Open up your Bomb Script and add the following variable at the very top:
    var prefab:GameObject;
    
  2. Then, just after the code where we detect a ground hit, add ...

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.