In an explosion, scraps can fly in all directions. We’re going to add some trails of fire to suggest that and add appeal to our effect. This is a good opportunity to learn to work with particle trails.
We’re going to design a single flying fire trail first and duplicate it later.
Add a new Node2D to the scene and name it FireTrails. We are going to use it to group all the fire trails together. Then, add a new Particles2D as child of the FireTrails and name it FireTrailParticles2D.
For this effect, we’re going to use the puff_smooth.png image instead. You can find it inside the assets/ folder. Assign it to the node’s Texture property.
This texture is smoother than the puff.png we used before. Having some softness in the source image makes the particles in the trail blend better with each other.
Increase the Amount to 50
and decrease the Lifetime to 0.5
. In the case of a trail, the Lifetime affects how far the particles travel before they disappear. Also increase the particle system’s Randomness to 0.5
. These values will make the trails long enough and a little fuzzy.
Toggle off Local Coordinates so the motion of the particles is independent of the node’s location.
At this point, your node’s settings should look like this:
Next, create a new ParticlesMaterial in the Material slot and left-click on it to display its properties in the Inspector.
Godot’s particle material has a Trail category that can produce trails. It does so by spawning a given amount of particles with the same start parameters and makes them move in the same direction.
Expand the Trail category and set the Divisor to 50
, like our particle node’s Amount. The Divisor controls the number of particles that make a single trail.
Since we want the trails to fly in all directions, we need to increase the Spread of the particles as we did with the FireBurstParticles2D and the SmokeCloudParticles2D. As we’re using the Trail property now, the Spread will only affect the first particle of each trail.
Set the Direction > Spread property to 180
. This allows each trail to move in a random direction.
Increase the Initial Velocity > Velocity to 1000
to make the scraps fly fast away from the explosion’s center. Drag the Velocity Random property slider to 0.4
. You can left-click on the slider to manually type the value.
Let’s also disable the gravity. In the Gravity property set all values to 0.0
.
The fire trails can fly from any point of the explosion. Let’s simulate that as well. Change the Emission Shape > Shape property to “Sphere” and set the sphere’s Radius to 15.0
pixels.
We want to give our trails a curving path to make them look more interesting. We can achieve that with tangential acceleration. Set the Tangential Accel > Accel to 1000
. This makes the particles accelerate in a direction perpendicular to their initial direction.
To make the trail curve the trail’s movement, let’s increase the Orbit Velocity > Velocity property to 0.3
. This value represents how many turns the particles perform around the emission point during their lifetime. In our case this a third of a turn.
Let’s randomize the movement to make each trail perform a different motion. Drag both the Orbit Velocity > Velocity Random and the Tangential Accel > Accel Random sliders to 1.0
, this allows for a range of trajectories, including straight ones.
Let’s refine the effect by making the particles decelerate and fade out.
To make the trail slow down, set the Damping property to 1500
.
Next, we want the trail to shrink in size over time to make it feel like it disappears in the distance. In the Scale category, decrease the Scale property to 0.2
. Set the Scale Random to 0.2
as well to give the particles a random variation of size, up to 20%.
Once again, let’s animate the particles’ scale over their lifetime. Assign a new “CurveTexture” to the Scale Curve property. Draw a curve similar to the one of the smoke cloud’s.
Finally, to make the fire trail extinguishes as it flies move to the Color > Color Ramp property and create a new Gradient. It should be reversed compared to the one we used in the FireBurstParticles2D. Start with an opaque dark gray and end with a transparent white. The gradient is going to appear over the trail, with the first particle being white and the last ones dark gray.
Now that we have one fire trail working, we can duplicate the FireTrailParticles2D to have multiple trails and control the timing of their emission. Another option would be to increase the Amount of the particles node but trails would appear one after the other and not at the same time.
Duplicate the FireTrailParticles2D four times for a total of five trails. Notice how each trail flies in a different direction. Together, all trails should look like a single effect.
That is it for the flying scraps. In the next lessons, we are going to add round sparkles.