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.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Introduction to Unity: Particle Systems
25 mins
- Getting Started with Particle Systems
- Adding a Particle System
- A Closer Look at a Particle System
- More Main Module Properties
- Introducing the Emission Module
- Adding a Custom Texture
- Changing the Particle System’s Shape
- Changing Size Over Lifetime
- Building a Bomb (Effect)
- Building the Explosion
- Changing Color
- Where to Go From Here?
Building the Explosion
To improve the explosion, you’ll alter the properties of one of the particle system’s modules. Can you guess which module to alter? Here’s a hint — you’ve already used it.
If you guessed the Emission module, give yourself a pat on the back!
Expand the Emission Module. Rate is the number of particles spawned per second. For this explosion, you won’t want a steady flow of particles, but rather a sudden burst.
Set the Rate over Time to 0. Now look beneath the Rate over Distance, and you’ll see a list of Bursts that’s empty by default:
A Burst is a collection of particles emitted all at once at a particular point in time.
Click on the + button at the bottom right to add a new Burst. You’ll see two fields: Time and Count:
Leave the Time at 0, and set Count to 150. These settings will make the particle system emit 150 particles all at once at the start of the system.
Play your scene; how do things look now?
Now that looks more like an explosion! While this explosion looks better, the shape is still an awkward cone and the particles don’t fade out — they simply disappear. You’ll need to mold your explosion to give it that final touch.
To get started, expand the Shape Module:
You’ve already used this module for the torch’s fire shape, but there are several more shapes to choose from. Click on the dropdown box that says Cone to see all options available to you:
Each shape affects the emitter in a different way. Each animation below shows the same emitter, with only the shape changed:
Sphere
HemiSphere
Cone
Box
Mesh (Cube)
Circle
Edge
You can get many different effects from the same system — simply by changing the shape! To create a realistic explosion, set the shape to Sphere.
Run the scene and prepare to be blown away:
Now that looks awesome!
While the explosion looks good, there’s one small problem. The particles simply disappear. This is a jarring effect and doesn’t look natural at all. Rather than just disappear, the particles should fade over time to make the explosion fade away.
Changing Color
With the particle system open in the Inspector, click the checkbox next the Color over Lifetime module to enable it and expand it. You’ll be greeted by the word Color and what looks like a white block next to it. Click on the white block:
This opens up the gradient editor:
The color change over the lifetime of the particles is represented as a gradient bar. The starting color is on the far left, and the particles will transition to the color on the right side:
The four white arrows at the edges are known as markers; click between two existing markers to add a new one. To remove a marker, drag it off the bar:
The top markers handle the Alpha or opacity of the color, while the bottom markers manage the RGB (Red, Green, Blue) color values.
Click on the right-most alpha marker. The bottom of the Gradient editor now shows the current alpha value:
Drag the slider all the way to 0. Now the particles will gradually fade away over the course of their lifetime.
Run your scene once again to see the effect of your changes:
That’s one hot explosion!
Want extra credit? Return to the torch scene and configure the flame to use Size Over Lifetime Module to achieve a similar effect.
Where to Go From Here?
You can download the final project here.
In this tutorial, you’ve learned how particle systems and its various modules work in Unity, and how to tweak them to get exactly the effect you want. Feel free to experiment with the different settings to see what other cool effects you can achieve.
For more information on the Shuriken Particle System and its modules, take a look at Unity’s official documentation and their Particle System video. You can also learn more about scripting particle systems here.
Did you know the Unity team has created a book? If not, check out Unity Games By Tutorials. The book will teach you to create four complete games from scratch:
- A twin-stick shooter
- A first-person shooter
- A tower defense game (with VR support!)
- A 2D platformer
By the end of this book, you’ll be ready to make your own games for Windows, macOS, iOS, and more!
This book is for complete beginners to Unity, as well as for those who’d like to bring their Unity skills to a professional level. The book assumes you have some prior programming experience (in any language).
I hope you enjoyed this tutorial; if you have any comments or questions, please share them in the discussion below!