Create 2D particle effects
Tutorial
·
Beginner
·
+10XP
·
30 mins
·
(296)
Unity Technologies

You have a fully-functioning game, but visual flair can make a big difference. In this tutorial, you’ll add 2D particle effects to your 2D adventure.
By the end of this tutorial, you’ll be able to do the following:
- Configure a looping particle system to achieve a visual effect.
- Adjust the EnemyController script to end the visual effect when the enemy character is fixed by the player.
- Configure particle systems using burst emission.
Languages available:
1. Overview
You’re now putting the finishing touches to your game. Visual effects (VFX) are a great way to create a more engaging and polished experience. Effects can also help to make the world of the game feel grounded — even a 2D game!
For your 2D adventure game, you’re going to create a smoke effect for broken enemies. You’ll create this effect using a particle system: a large group of tiny images or meshes (particles) that Unity simulates to create the impression of an effect like smoke, snow, sparks, or fire.
By the end of this tutorial, you’ll be able to do the following:
- Configure a looping particle system to achieve a visual effect
- Adjust the EnemyController script to end the visual effect when the enemy character is fixed by the player
- Configure particle systems using burst emission
Working on your own project?
This tutorial is part of Beginner 2D: Adventure Game and refers to the game project for that course, but this information may be helpful for any beginner creator who wants to add 2D particle effects to enhance their own game. If you have no previous experience of visual effects (VFX) in Unity and are not completing the Beginner 2D course, Creative Core: VFX will guide you through the basics.
Note: For the purposes of this tutorial, we chose to use the Ruby’s Adventure asset set, and the file paths used in instructions will reflect this. If you chose another asset set, the file names will be the same, but in your corresponding theme folder.
2. Prepare the spritesheet for particle effects
Your adventure game doesn’t need particularly complicated effects, so you’re going to use Unity’s Built-in Particle System to create effects.
To prepare sprites to use in your smoke particle system, follow these instructions:
1. In the Project window, in the folder for your chosen asset pack, navigate to Art > [Your Chosen Project]> VFX. Select the ParticleSpriteAtlas asset.
2. In the Inspector window, set the Sprite Mode property to Multiple.
3. Check that the Pixels Per Unit is set to 100.
4. Open the Sprite Editor window and slice the sprite atlas into a 4 by 4 grid. (Or in an appropriate grid for its layout, if you are using your own alternative sprite sheet.)
3. Create a smoke effect
To create a smoke effect particle system, follow these instructions:
1. In the Hierarchy window, select Add (+) > Effects > Particle System. In the Scene view, the default effect is represented by white dots being emitted from a source point. You can pause the simulation using the Particles overlay.
2. Rename the ParticleSystem GameObject “SmokeEffect”.
Note: If you need to, you can reposition the SmokeEffect GameObject in the Scene view to make it easier to see the preview.
3. Select the SmokeEffect GameObject. In the Inspector window, review the Particle System component. A variety of different properties are displayed, and many of these properties are expandable. The properties control the behavior of the particle system and the individual particles that it creates.

4. Enable the Texture Sheet Animation module, toward the bottom of the property list. Select the module name to expand its properties.

5. In the module, set the Mode property to Sprites.
6. Select the Add (+) button next to the empty sprite property to create two fields. Assign the two smoke sprites from ParticleSpriteAtlas using the Sprite picker (⊙) and search functionality.
7. Open the Start Frame dropdown and select Random Between Two Constants. Set the second Start Frame value to 2.
Note: The Start Frame value might change to 1.9998 after you’ve set it. If this happens, don’t worry; the effect will still work as expected!

8. Select the Frame Over Time box. When the particle system creates a new particle, it will pick a random value between 0 and 2 (excluding 2) and use the corresponding sprite for the new particle.

The visualization in the Particle System Curves pane at the bottom of the Inspector window shows how the frame will change over time, from frame 0 to frame 1. However, you don’t want animated particles — each particle will be one sprite or the other.
9. Right-click the key frame on the right of the visualization and select Delete Key.
4. Configure the Shape module
In the Scene view, the particles are now one or other of the smoke sprites! Now it’s time to refine the effect. The particles currently have a wide spread, indicated by the white cone in the Scene view, which isn’t a particularly effective representation of the smoke that might come from a broken robot.
To start to adjust this issue by changing how the particles are created, follow these instructions:
1. In the Particle System component, open the Shape module.

2. Set the Radius property to 0 so that all particles start from a single point.
Note: This value will change to 0.0001, which is the closest value to 0 that Unity can accept here.
3. Set the Angle property to 5 so that the particles are less spread out and generated in a straighter line. You can adjust this value further to customize your effect later, if you like.
4. Save your changes so far.
The particles are now being generated from a single point and have an improved direction for the smoke effect, but they are still moving too fast. The effect also looks quite artificial — the particles are both a very similar shape and they lack the randomness of real smoke.
5. Add more randomness to the particle system
To add additional randomness to the particle system, to create a more realistic effect, follow these instructions:
1. In the Particle System component’s main module, find the Start Lifetime property.

A particle’s lifetime is how long it is rendered before it gets destroyed by the particle system. If you zoom out in the Scene view and play the preview, you’ll notice that the particles disappear around the same place. The particles all currently have the same lifetime and speed, so they end up being destroyed at the same distance.
2. Open the Start Lifetime property dropdown and select Random Between Two Constants.
3. Set the Start Lifetime values to 1.5 and 3.
This change means that the particles will have a shorter lifetime in general and that the lifetime will be variable for each particle.
4. Repeat the process for the following properties:
- Start Speed, setting the two values to 0.5 and 1.
- Start Size, setting the two values to 0.3 and 0.5.
Now the smoke effect is more intense and on a much more constrained scale, which is a good fit for a broken machine.
The effect is still a bit strange — particles just disappear at the end of their lifetime. A fade of the particles before they disappear would feel more realistic.
6. Fade particles at the end of their lifetime
You can create a fade for your smoke by increasing the transparency of the particles as they get closer to the end of their lifetime.
To configure the fade effect, follow these instructions:
1. In the Particle System component, enable and open the Color over Lifetime module.

2. Select the Color box to open the Gradient Editor.

This gradient shows how the color of a particle changes over its lifetime. At the moment, the particle is the default white throughout its lifetime (you haven’t added any color) and there are no transparency changes.
3. Select the marker on the upper-right corner of the gradient box.

4. Set the Alpha to 0. This property controls transparency — now over each particle’s lifetime, the sprite will fade to transparent.

5. In the Particle System component, enable and open the Size over Lifetime module.
6. Select the Size box.

The visualization in the Particle System Curves pane shows that the particles are currently growing in size over their lifetime, from 0 to their maximum size.
7. Select the fifth preset option, which sets the maximum size at the start of the particle lifetime and a size of 0 at the end with a curve.

8. Hold Ctrl (macOS: Cmd) and select the start and end points, then use the tangent that appears next to each point to control the curve and drag to change the size reduction over time. Adjust the curve until you’re happy with the result in the Scene view — for more realistic smoke, make the curve stay flat until at least half of its lifetime and then steeply decrease its size.
9. Save your changes.
7. Add the particle system to the enemy
Now you’re created and configured your smoke effect particle system, you’re ready to add it to the enemy to play whilst the enemy is broken.
To set up the enemy smoke effect, follow these instructions:
1. Create a prefab from the SmokeEffect GameObject and delete the version in the scene.
2. Open the Enemy prefab.
3. Drag the SmokeEffect prefab from the Project window and release it over the Enemy GameObject in the Hierarchy window to make the SmokeEffect prefab a child GameObject of the Enemy GameObject.

4. In the Scene view, select Move in the tools overlay and position the SmokeEffect GameObject so that the smoke appears to be coming from the Enemy GameObject.
5. Save your changes and exit prefab editing mode.
6. Test your game and try throwing a projectile at the enemy.
You’re almost done! The smoke effect definitely makes it more clear that the enemy is broken, but there are still two things that aren’t quite right:
- The smoke is moving with the enemy, which is not how smoke behaves in the real world.
- The smoke continues after the enemy is fixed, rather than ending to reflect the fixed state.
8. Fix the smoke issues
The two issues that you’ve identified have separate solutions.
Fix the smoke movement
To fix the smoke movement, follow these instructions:
1. Open the Enemy prefab. In the Hierarchy window, select the SmokeEffect child GameObject.
2. In the Inspector window, go to the Particle System component’s main module. Find the Simulation Space property.

3. Open the Simulation Space dropdown and select World. This change means that the particles will move in the world space for your game, rather than moving in the parent GameObject’s local space (and therefore following the enemy patrol).
4. Save your changes and exit prefab editing mode.
Stop the smoke effect
To end the effect when the player has fixed the enemy, follow these instructions:
1. Open the EnemyController script in your IDE.
2. At the top of the Enemy Controller class, add a new public class member of type ParticleSystem:
Here’s an explanation of this code:
- If a public member is a component type rather than a GameObject, when you assign a GameObject with the specified component then Unity will store a reference to the component.
- This approach to getting the reference means that you don’t need to use GetComponent and also means that you can’t accidentally assign a GameObject without the specified component.
3. In the Fix function, at the bottom of your script, add the following instruction:
This instruction stops the particle system, rather than destroying it. When you destroy a particle system, you also destroy all the particles that it is currently handling. Stopping the system means that no new particles will be created, so it’s a more natural-looking way to end the effect.
4. Save your changes and return to the Unity Editor. Exit prefab editing mode, and in the Scene view, select the Enemy GameObject and review the Enemy Controller (Script) component in the Inspector window — you’ll now find a new Smoke Effect property listed.

5. Drag the SmokeEffect child GameObject from the Hierarchy window and release it over the Smoke Effect property to assign it.
6. Save your changes and apply the override to the prefab.
7. Test the game — the effect now ends when the enemy is fixed.
9. More to try
Now that you know how to configure a basic particle system, you can create other effects for your 2D adventure game. The ParticleSpriteAtlas asset in your chosen asset pack also includes sprites designed for effects when the player character takes damage and when they pick up a health collectible, but you can also use your own sprites or create different effects to suit your specific game.
As you create more effects, play around with the settings to try and create something that fits with your vision for the game. You can also refer to Creative Core: VFX if you’d like a little more support than the guidance below.
Limited-time particle effects
The smoke effect that you created loops until the player fixes the enemy, but you can also create particle systems that run for a finite time.
To configure a particle system to run for a limited time, follow these instructions:
1. In the Particle System component, go to the main module.
2. Disable Looping.
3. Set the Duration property to your desired length for the effect to last (in seconds).
4. Open the Stop Action property dropdown and select Destroy. This selection means that the particle system will only be destroyed after the lifetime of its last particle has ended, so you won’t encounter the problem of everything immediately disappearing.
Burst emission
Your smoke effect was emitting particles at a steady rate. You can set that rate in the Emission module using the following properties:
- Rate over Time: controls how many particles are emitted per unit of time.
- Rate over Distance: controls how many particles are emitted per unit of distance moved (which can be useful if you only want a visual effect to work when something is moved, such as exhaust smoke for a vehicle).
However, for some effects you might want to emit a lot of particles at once; when something explodes or when the player is hit, for example. You can use burst emission to configure the system to emit particles in one or more large bursts.
To configure a burst for a player hit effect, follow these high-level instructions:
1. In the Particle System component, go to the main module.
2. Disable Looping.
3. Open the Stop Action property dropdown and select Destroy.
4. In the Emission module, set the Rate over Time property to 0. This effect is going to create a single burst of particles, not keep emitting them over time.
5. In the Bursts list of the Emission module, select Add (+).
6. Set the Count to 20. Keep the default Time value of 0.00.

As soon as the particle system is created, it will emit 20 particles and then destroy itself once those particles reach their end of lifetime.
Instantiate a particle system
Once you have created a prefab for a particle system, you can create one in the game using the Instantiate function. For an effect that should happen once, like a hit or pickup effect, you need to do the following:
- Store a reference to the prefab in a public variable, as you did for the smoke effect.
- Call Instantiate when the effect should happen. For example, to play an effect when the player picks up a health collectible, this would be the if statement code block within the OnTriggerEnter2D function in the HealthCollecible script, just like the instruction to play the collection sound effect.
If you have configured the system burst emission as outlined in the instructions above, the effect will play and then the particle system will be destroyed.
10. Check your script
If you’re completing the 2D Beginner course, take a moment to check that your scripts are correct before continuing.
EnemyController.cs
11. Next steps
Visual effects are a great way to add overall polish to your game and to make its world feel more cohesive and engaging. Next, if you have previous art experience, we’ll guide you through creating your own hand-drawn animations for your game. If you don’t have experience in this area, you can skip ahead to Build and share your game.