Dust Trail EffectUnity Particle Effect When Running and Jumping

Author Waldo
Published September 1, 2019

In this video we re-create the dust trail effect from games like Super Mario World and Celeste

Video Walkthrough

  • 0:30 - Adding Particle System
  • 1:30 - Setting the position and scale of the particle system
  • 2:35 - Setting the Color and Speed of the Particle System
  • 3:15 - Removing the loop and pressing Play during through our C# script
  • 4:28 - Duration, Emission Rate, Lifetime and Simulation Space
  • 5:24 - Finished Product

Part 1 - ADDING PARTICLE EFFECT SYSTEM

  1. The first thing we want to do is add a Particle Effect as a child object of our Player Object by right clicking and selecting Effects and then Particle Effect.
  2. Right off the bat I see a bunch of giant black squares oozing from behind my player.
  3. We will fix that in a second, but for now let’s give our new Particle System a name.
  4. I’ll just go ahead and name this one DustPS.
  5. Then let’s scroll to the bottom until we see a category called Renderer and let’s click to expand it.
  6. To change the look of these black shapes, I’m going to change the material to Sprites Default.
  7. This works great for my Pixel Art styled game, but any type of Material could work here, so adjust this as you need.
  8. If you don’t see anything on your screen it could either be because your particle effect is behind your camera or it’s behind other objects.
  9. To adjust this we can change our Sorting Layer ID and for this video I’m going to place it on the same layer as my player.
  10. Then below that I’m going to give it a negative order value this way it’s behind my player but renders above everything else.

Part 2 - SETTING THE POSITION AND SCALE OF THE PARTICLE EFFECT

  1. If it’s still not showing up for you, let’s go back to the top and right click to reset the transform so it zero’s out our position.
  2. This makes our Z position equal 0 which should position it infront of your camera if it’s not set to that already.
  3. Then I’m going to move this down so that the entry point is at the very bottom of my object.
  4. For my player this just happens to be negative .52
  5. This is kind of hard to see, so let’s go down to where it says Start Size and let’s change this value from 1 to 0.1
  6. And immediately you should see it now looks a lot like our snow effect, but we can change that by controlling the Shape.
  7. So let’s scroll down to the Shape category and expand it.
  8. For this effect we want to use the Box shape.
  9. And then down below it we want to modify the scale values.
  10. Go ahead and set the Y value to 0.
  11. This should create a white line at the very base of our characters feet.
  12. Feel free to adjust the transforms Y value if it’s not exactly in this location.
  13. Then for the X value go ahead and adjust this so this white line is about the width of your object.
  14. For me this value is 0.5.

Part 3 - SETTING THE COLOR AND SPEED OF THE PARTICLE EFFECT

  1. Next let’s add some motion to our line.
  2. To mimic the effect of Dust, let’s change the velocity of our Particle Effect so our dust rises and fades away from our character.
  3. So first let’s scroll down to the Velocity Over Lifetime category.
  4. For Linear let’s change the X value to something like negative 0.2 and the Y value to positive 0.2
  5. Then we want our particles to fade over time, so let’s expand the Color over Lifetime category.
  6. Here is where we can change the color of our particle, but for this example I just want to set the Alpha to zero on the right side.
  7. This makes it so our particles fade out before they disappear completely.

Part 4 - REMOVING THE LOOP AND PRESSING PLAY DURING OUR SCRIPT.

  1. Now that that is starting to look better, we want to transform this particle so our character only kicks up dust at actionable moments like when he changes directions or jumps in the air.
  2. In order for that to work properly we actually don’t want this animation to Loop, so go ahead and uncheck the box where it says Looping and also the box where it says Play on Awake.
  3. Our Particle Effect should be more like a burst of dust then a constant snowfall.
  4. But in order for that to work, we must trigger the Play button during those actionable moments.
  5. We can do this in a script, so I’m going to go ahead and open up my Player script where I have my running and jumping functions setup.
  6. And the first thing I want to do is create a public ParticleSystem called dust.
  7. Then let’s just create a function called CreateDust and inside it let’s write dust.Play
  8. Now whenever we want our character to kick up dust we just need to call CreateDust.
  9. So for now I’m just going to place it in the function where I flip my character when he changes directions.

Part 5 - Duration, Emission Rate, Lifetime and Simulation Space

  1. Back in Unity, we want to drag our Particle Effect into the inspector where it says dust.
  2. Then when I press play and start the run and then change directions, we should see Particle Effect kick into action.
  3. Although as might notice this particle effect follows our character as he keeps running.
  4. The reason for this is because our particles are acting in a Local simulation.
  5. So to fix this let’s change the value for Simulation Space from Local to World.
  6. Let’s also do the same for Velocity over time.
  7. And while we’re at it, let’s add more particles to the scene by increasing the rate of emissions.
  8. So under Emissions, change the value for Rate over Time to something higher like 100.
  9. And upon testing we now have a cool dust effect whenever we change directions.

Part 6 - Final Product

  1. Now that we have the effect looking good, we can keep tinkering with these settings to adjust it how we like.
  2. For example we can lower the Start Lifetime value to control how long our particles last on the scene.
  3. For me I think a good number is about 0.5 and let’s also adjust our duration down to 0.1.
  4. And now we can also apply this effect to any actionable moment, like for example when our character jumps.
  5. All we have to do is call CreateDust anywhere in our script.
  6. And then when we test this in Unity, it works great.
  7. If you enjoyed this video and would like us to make more, please help us out by pressing the like button and subscribing to this channel so you don’t miss any future videos.

This tutorial is sponsored by this community

In order to stick to our mission of keeping education free, our videos and the content of this website rely on the support of this community. If you have found value in anything we provide, and if you are able to, please consider contributing to our Patreon. If you can’t afford to financially support us, please be sure to like, comment and share our content — it is equally as important.

Join The Community

Discussion

Browse Tutorials About