Time for action – adding explosions
A single particle system and script will allow us to create some nice explosions that can be used everywhere.
- We first need some new textures to make the explosion look like fire. Luckily, Unity provides a multitude of basic particle textures. To include them in your project, go to the top of the Unity Editor and navigate to Assets | Import Package | Particles.
- In the resulting window, select Import and wait for Unity to finish importing them. This package is a great resource, including both textures and complete particle systems. However, all of the particle systems included use the old system that will be phased out of Unity over the next few versions. Despite this, we can still make full use of the included materials.
- Create a new
particleSystem
object and name itExplosion
. - First, in the Initial module, we need to make the effect last for a short time. Set the Duration to 0.5 and the Start Lifetime option to 1.
- To keep the particles close...