Introduction to Unity: Particle Systems

Unity’s particle system is both robust and feature packed. In this tutorial, you’ll learn the ins-and-outs of it to create both fire and explosions. By Anthony Uccello.

Leave a rating/review
Save for later
Share
Updated for Unity 2017.2 by Anthony Uccello. Original tutorial by Eric Van de Kerckhove.

Particle systems are like salt; just a small amount can add extra “pizzazz” to whatever you’re cooking up. Modern games that don’t use particle systems in some manner can feel quite bland.

Back in the old days, you needed the black arts of graphics programming to create even a single wisp of smoke. Thankfully, Unity makes creating particle systems quite simple with a modular, built-in particle system named Shuriken, which is easy to learn but lets you create complex effects.

In this tutorial, you’ll learn the following:

  • How to add a new particle system in Unity.
  • What the most commonly used particle system modules do and how to use them.

This tutorial has two main parts; in the first part, you’ll build the flames of a torch. In the second part, you’ll create a bomb explosion effect.

Note: This tutorial assumes you understand the basics of working with Unity. If you are new to Unity, or need a refresher, please see our Introduction to Unity tutorial.

Getting Started with Particle Systems

Download the starter project for this tutorial and extract it to a convenient location. Note that you will need to use at least Unity 2017.2 to work with this project.

Open up the Starter Project in Unity. The assets inside are sorted into several folders:

  • Materials: Holds the fire material.
  • Models: Contains the torch and bomb models and their materials.
  • Prefabs: Holds the bomb prefab.
  • Scenes: Contains the Torch and Bomb scenes.
  • Scripts: Holds the initial scripts.
  • Textures: Contains the texture for the fire material.

Now that you’ve seen where everything is stored, you can start to learn how particle systems work in Unity.

Adding a Particle System

A particle system generally emits particles in random positions within a predefined space, which can have a shape like a sphere or a cone. The system determines the lifetime of the particle itself, and when that lifetime expires, the system destroys the particle.

One nice thing about particle systems is that they are components that you can add to any GameObject in the scene. Want to have your sharks emit lasers from their eyes? Simply add a particle system to the shark eye GameObject, and your sharks will be unstoppable!

Open up the Torch scene from your Project Window and run the scene:

There’s not much going on at the moment. The torch hangs on the wall, but there’s no fire to be seen. You’ll need to add a particle system first.

Stop running the scene and select TorchFireParticles inside the Hierarchy. Inside the Inspector, click the Add Component button. Search for Particle System and click to add it:

The Add Component screen with Particle System in the search field

Note: You might have noticed you didn’t add the particle system directly to the MedievalTorch GameObject. This is because the particles would be emitted from the middle of the torch, instead of from the fuel container at the top.

Play your scene; you’ll see you have particles emitting already:

Torch with particles emitting from it

Correct settings from the particle system's Renderer section

Note: You might see pink particles instead of white, which seems to be a Unity bug with setting the default texture. If that’s the case, don’t worry: you will set the proper fire texture shortly. If you’d like to fix it now, click the Renderer section of the particle system, click the Dot next to the Material field and double-click Default-Particle in the window that pops up.

When you select a GameObject with an attached particle system, you’ll notice a black dialog in the lower right-hand corner of the scene view. This dialog lets you simulate or stop the particle system. Clicking Simulate activates your particle system and changes the button to a Pause button. To stop the simulation, click the “Stop” button.

Dialog with stop, start and pause buttons

This dialog is useful for designing particle systems that run on a fixed timeline, such as explosions.

A Closer Look at a Particle System

Take a look at the Inspector. You’ll notice the particle system Component you added has several subsections:

How the particle system Component looks in the Inspector

Each of these subsections is called a Module. These Modules contain the settings for the particle system. The Module expanded by default is known as the Main module:

Main module showing the particle system

The Main module is the meat and bones of any particle system in Unity. The most common particle settings live here:

On & off

On & off

For your fire effect, leave this disabled to make it look like the torch was just ignited.

Top: 8 seconds
Bottom: 3 seconds

Set the lifetime to 4 seconds; this ensures the flame won’t be too tall.

Top: 2
Bottom: 10

Set the speed to 0.75; this will make the fire effect slower and more dense.

  • Duration: The length of time in seconds for the particle system to run. Leave this at the default value of 5.00.
  • Looping: Repeatedly emit particles until the particle system stops. The cycle restarts once the Duration time is reached. The fire needs to burn continuously, so leave this enabled.
    Difference between looping on (left) and off (right)
  • Prewarm: Only used when Looping is enabled. The Particle System will act as if it’s already completed a full cycle on start-up.
    Difference between prewarm on (left) and off (right)
  • Start Delay: The delay in seconds before the particle system starts emitting. Leave this at the default value of 0.
  • Start Lifetime: The initial lifetime in seconds for the particles. The particle is destroyed after this elapsed time.
    Start lifetime of 8 seconds (top) and 3 seconds (bottom)
  • Start Speed: The initial speed of the particles. The greater the speed of the particles, the more spread out they will be.
    Difference between a start speed of 2 (top) and 10 (bottom)
Difference between looping on (left) and off (right)
Difference between prewarm on (left) and off (right)
Start lifetime of 8 seconds (top) and 3 seconds (bottom)
Difference between a start speed of 2 (top) and 10 (bottom)
Note: As you modify the settings of the particle system, you’ll see a preview of it in the Game Window. Keep an eye on this preview while following along with the tutorial.

Before continuing, run your scene to see the effect of your changes:

Torch emitting particles after the changes you made above

You’ve set up the torch, but the fire effect still leaves a lot to be desired. Thankfully, the Main module has additional options to further refine the shape and behavior of your torch.

More Main Module Properties

Select the TorchFireParticles GameObject in the Hierarchy and scroll down to the particle system. Under the Main Module, take a look at the following properties:

Top: 0.2
Bottom: 1

Set the size to 3; this is a manageable size that lets you see the individual particles more clearly.

Top: 0°
Bottom: 45°

Keep the rotation at ; the particles are round so you will hardly notice the difference.

Particles falling downwards due to the gravity effect
The image above is from a system with the gravity modifier set to 1, which makes the particles flow down like a waterfall. Leave the gravity in your system at 0; the particles will move upwards with the velocity you set in Start Speed.

Top: local space
Bottom: world space

Leave your simulation set to Local Space. The effect will only be visible once the particle system is moved.

  • Start Size: the initial size of the particles.
    Difference between a particle size of 0.2 (top) and 1 (bottom)
  • Start Rotation: The initial rotation angle of the particles.
    Difference between a start rotation of 0° (top) and 45° (bottom)
  • Start Color: The initial color of the particles. Keep the color at the default value of pure white (255,255,255); you’ll color the fire via a texture.
  • Gravity Modifier: Scales the gravity value set in Unity’s Physics Manager window. If it’s set to 0, the gravity will be turned off.
  • Simulation Space: Moves particles in Local Space along with the particle system. While in World Space, particles move freely once emitted.
    Difference between the local space effect (top) and world space effect (bottom)
  • Play On Awake: Starts emitting immediately when enabled. If this is turned off, you have to manually start the particle system via script or an animation system. Leave this setting on, as you want the fire to start when the scene starts playing.
  • Max Particles: The maximum number of particles the system may have alive at once. If you try to emit more particles than this, they won’t be emitted at all. This setting is primarily for performance reasons, and the default value of 1000 particles is more than enough in this case.
Difference between a particle size of 0.2 (top) and 1 (bottom)
Difference between a start rotation of 0° (top) and 45° (bottom)
Difference between the local space effect (top) and world space effect (bottom)

Whew, that was quite a list! But as a result, you’ve learned how to add a particle system to your scene and how to customize it to your liking.

Run your scene again to see the effect of your changes:

Torch with particles that look much more like fire

It looks a bit more like fire every time, doesn’t it?

It needs more particles though. To do that, you need to change the emission of the system.