Unreal Engine 4 Particle Systems Tutorial
In this Unreal Engine 4 tutorial, you will learn how to create particle systems and update them using Blueprints. By Tommy Tran.
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
Unreal Engine 4 Particle Systems Tutorial
25 mins
- Getting Started
- What is a Particle System?
- Creating a Particle System
- Cascade: The Particle System Editor
- Applying a Material to Particles
- Attaching the Particle System
- Setting a Particle’s Velocity and Size
- Setting the Particle’s Size
- Increasing the Particle Spawn Rate
- Shrinking the Particles Over Time
- What is a Curve?
- Modifying a Module’s Curve
- Adding Color Variations
- The Initial Color Module
- Toggling the Particle System
- Creating an Explosion Effect
- Creating a Burst
- Moving the Particles Outwards
- Setting the Emitter Loops
- Spawning Particles on Enemy Death
- Changing the Explosion Color to Enemy Color
- Setting Particle Parameters Using Blueprints
- Where to Go From Here?
Creating a Burst
First, you will need to set the spawn rate to zero because you don’t want to use the default spawning behaviour. Select the Spawn module and set Spawn\Rate\Distribution\Constant to 0.
Next, you need to tell the emitter you want to create a burst. Scroll down to the Burst section and add a new entry to the Burst List. You can do this by clicking the + icon.
Each entry will contain three fields:
- Count: How many particles to spawn. Set this to 20.
- Count Low: If greater than or equal to 0, the amount of particles spawned will range from Count Low to Count. Leave this at -1.
- Time: When to spawn the particles. A value of 0 indicates the beginning of the emitter’s lifetime. A value of 1 indicates the end of the emitter’s lifetime. Leave this at 0.0.
This means the emitter will spawn 20 particles at the beginning of its life.
To make it look like an explosion, you need to set the velocity so that the particles move outwards.
Moving the Particles Outwards
Since this is a top-down game, you only need to specify the X and Y velocities. Select the Initial Velocity module and expand Start Velocity\Distribution. Set Max to (1000, 1000, 0) and Min to (-1000, -1000, 0).
By specifying a range that goes from negative to positive, the particles will move outwards from the emitter.
Next, you need to set the amount of times the emitter should loop.
Setting the Emitter Loops
By default, emitters will loop indefinitely. This is great for effects such as fire and smoke but a burst should only play once. To fix this, you need to tell the emitter to only loop once.
Select the Required module and then locate the Duration section. Set Emitter Loops to 1.
Now, it’s time to play the explosion when an enemy dies!
Spawning Particles on Enemy Death
Go back to the main editor and navigate to the Blueprints folder. Open BP_Enemy and then locate the OnDeath event.
To spawn a particle system, you can use a Spawn Emitter at Location node. Create one and connect it to Destroy Actor.
Next, set Emitter Template to PS_Explosion.
Finally, create a GetActorLocation and connect it to the Location pin.
Now, when an enemy dies, it will spawn an instance of PS_Explosion at the enemy’s location.
Click Compile and then go back to the main editor. Press Play and start shooting some baddies.
Look at all those explosions! Next, you’ll add some extra spice to them by making them the same color as the enemy.
Changing the Explosion Color to Enemy Color
To use the enemy’s color, you need a way to receive that information from Blueprints. Luckily, Cascade has a distribution type that allows for this.
Open PS_Explosion and select the Initial Color module. Set Start Color\Distribution to Distribution Vector Particle Parameter.
This will give you a parameter that you can set using Blueprints. Set the Parameter Name to PrimaryColor
For the explosion, you will use both of the enemy’s colors. To use the second color, you will need another emitter. Right-click an empty space on the emitter and select Emitter\Duplicate and Share Emitter. This will duplicate the emitter.
You’ll notice that each module now has a + sign next to it. By using Duplicate and Share Emitter instead of Duplicate, you have linked the modules instead of copying them. Any changes you make in one module will also happen in the same module of the other emitter. This is useful if you want to change properties across all emitters such as size.
The only module you will need to change is Initial Color. However, if you make a change, both emitters will receive the change. In this case, you do not want the modules to be linked as they need individual parameter names. The easiest way to unlink them is to delete the duplicated Initial Color module and create a new one.
Select the new Initial Color and set Start Color\Distribution to Distribution Vector Particle Parameter. Next, set Parameter Name to SecondaryColor.
At this point, the particle system is complete. Close PS_Explosion.
Next, you need to set the parameters using Blueprints.
Setting Particle Parameters Using Blueprints
Open BP_Enemy and then add the highlighted nodes after Spawn Emitter at Location:
This will allow you to set two parameters within PS_Explosion.
Now, you need to set the correct parameter names. Set Parameter Name for the first Set Color Parameter to PrimaryColor. Set Parameter Name for the second Set Color Parameter to SecondaryColor
Finally, you need to provide the colors. To make things easier, the colors have already been stored in the variables PrimaryColor and SecondaryColor. Connect each variable to their respective nodes like so:
Here is what you should end up with:
Let’s go over the order of events:
- When an enemy dies, it will spawn an instance of PS_Explosion at its location
- The PrimaryColor parameter of PS_Explosion will be set
- The SecondaryColor parameter of PS_Explosion will be set
Click Compile and then close BP_Enemy. Press Play and start shooting enemies to see the particle mayhem!
Look at all those juicy particles. See if you can add an explosion when the player dies!
[spoiler]
- Open BP_Player and locate the OnDeath event
- Add a Spawn Emitter at Location node to the Then 1 pin of Sequence. Set Emitter Template to PS_Explosion.
- Create a GetActorLocation and connect it to the Location pin of Spawn Emitter at Location
- Create a Set Color Parameter and connect it to Spawn Emitter at Location. Set Parameter Name to PrimaryColor and connect the PrimaryColor variable to Param.
- Create another Set Color Parameter and connect it to the first Set Color Parameter. Set Parameter Name to SecondaryColor and connect the SecondaryColor variable to Param.
[/spoiler]