Time for action – kill kill murder die

An explosion like this can't be allowed to roam the streets, wreaking its flaming spite on unsuspecting civilians. It must be stopped. And you, being a video game programmer, are the only person who can stop it.

Write a quick script to determine when the last particle in the explosion has run its course, and then destroy the explosion. It's the only way.

  1. Create a new JavaScript called DestroyParticleSystem, and attach it as a component to Explosion.
  2. Modify the script thusly:
    function LateUpdate ()
    {
      if (!particleSystem.IsAlive())
      {
      Destroy (this.gameObject);
      }
    }

    The built-in LateUpdate function fires after all Update function calls have finished.

  3. At the moment, if you click to view the Explosion Prefab in the ...

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.