Hello, guys.
In this video, we're going to talk about particles.
I'm going to show you how to create a simple dust effect.
And before we begin, I want to tell you that particles are entire complicated system that can be in
their profession.
For some people, it is what they say.
Easy to learn, hard to master.
You can make lots of different stuff.
You can make a snow effect.
Fire explosion.
I'm going to show you some examples later in the course, what other people can do.
But in this video, we're going to focus on making simple dust effect.
And then I'm going to make one more video showing what you could do, possibly with particle system.
Okay, let's do dust.
First.
What we need to do is go to effects particle system, and I want to name it Dust Effect, dust picks.
We're going to change rotation to zero because at the moment you can see that particles are flying up
if you see it in 3D space.
But we are into this space, so we need to make it zero rotation on the X and now they're going to fly
kind of like kind of like away from the camera.
But it doesn't matter for us much because we use in 2D.
Let's go back to 2D and I want to place them at the feet of the character over here.
Next step would be to make them visible.
We can do it with a certain layer.
Let's go all the way down to renderer.
Find a certain layer over here.
Let's change it to player and set it to minus one.
So it will be always behind the player but in front of everything else.
Good enough.
We can go to material now and change it to a sprite default.
Now it looks more like a pixels like what we need.
Let's go all the way above.
And I think that can the big so we can make them much smaller.
We can do that by changing start size to point.
To.
That's good.
Now we can see that our particles are spreading all the way around, and we need to keep them at one
place to do that.
We can go to shape over here and change this shape from cone to box.
Now they all in the same box.
And what I want to do here is to change the size of this box.
And when I place it at the feet of the character and change scale on the Y to basically zero.
Good.
Now there are particles and they move in, but they move in to a different direction.
So we cannot see it.
What we need to do is to make them move up and left.
We can do that by changing velocity over lifetime.
Let's click it here.
Let's find it Velocity over lifetime.
Open it and we're going to change the speed of the X to minus one and speed of the Y to something like
two.
Now it goes up and left and that is good.
Pretty much looks like a dust.
What we want to do next is to go above and make them exist for less time.
Because now you can see they are flying high and we need just a short burst of the particles.
We can do that by change in duration from five to something like point five.
And I want to uncheck looping over here and uncheck play on Awake.
Now, particles will be there only when you play them.
Let's try this play.
It's going to fly like that and it looks more like what we need, right?
Just a short burst.
If you click restart, it's going to be there again.
We can make more of them by changing emission over here.
Let's go and do that.
And we can set value to really high to something like 100.
Let's see this now.
This is more like a dust.
And now we want to make it disappear with the time, because at the moment is just a bunch of white
cubes there.
What we can do is go to color over lifetime and change this color.
And let's click it first open.
And we can change color of a lifetime by clicking the bottom one and change it to something like red.
Let's just see, for example, you see they turn in red with a time.
Or.
We can keep the color as it was, but change the alpha to make it transparent.
And now you can see they disappear in.
It looks much better.
Now I want to lower duration time even more.
I want to set it to point one.
And this is really look like a dust.
To make it fly faster because now it's kind of floaty.
We can change simulation speed to something like three or four.
Let's try it.
I beat fast.
So maybe to.
Yeah, this looks better.
And now let's try and play these particles when we need to.
I'm going to make a child of the character.
And more with Tumblr below.
Let's go to player and I want to make another header for visual effects of the character header and
we fix.
And here we're going to do serialize field private particle system.
That's the fix.
Good.
Now when we want to play dust when our player jumps, for example.
So let's go and find John Button.
And by the way, we can get in lots of same lines of code.
So maybe we should modify script just a bit.
Let's do this.
Let's create a jump function over here.
Private void Jump.
I'm going to duplicate this line of code, paste it in here, but I want to pass jump force as a parameter.
So force.
And here instead of jump four is going to be force.
Now we can cut out the music or the effect line.
Paste it in here and now I will.
Please just a jump function here and I'll pass it.
Jump first.
And for this one, we're going to do jump.
And I'm going to pass double jump force.
Cool.
Now we only need to change.
Jump once in the function and it's going to be fine here and there.
Yeah, I like it more.
All right, So here we can play the dust and dust fix Dot play.
Pretty simple.
That's it.
That's all what we need to do.
I think we could play dust when we slide in.
So let's do it here.
That's the picks that play.
We need to assign dust effect, so let's do it.
And in the play mode, we want to see how does it work.
We still need to fix something, but we'll do it after we seen this one.
So there is a dust and it's fine.
Then the problem is we can see it's still child of the player and it stays in most together with the
player, which looks really weird.
What we can do here is to go to dust effect.
I'll mute the game, by the way.
We can go to dust effect, find simulation space and change it to world.
And very same we need to do in the velocity over lifetime.
Bald.
Now it is much better.
I'll try to do slide.
I know.
Well, particles were there.
I wonder what if we change velocity of our lifetime to smaller value to something like -0.2 and for
the Y point three?
Let's see now.
Yeah, this is better.
We can increase simulation speed.
Let's try.
Yeah, this is much better.
Let's keep this one.
Now I feel like it would be nice to play particles on Linden as well.
And we can do that.
We just need to modify a script a bit.
Let's go to the player script somewhere in the movie info.
We can just create a boolean private ball.
Ready to land.
And we're going to set it to true when player is in the air and when he is, let's say, decrease in
fallen.
Yeah.
So let's do this.
Let's just do it in the update.
If our velocity that Y is less than minus five and not as grounded then ready to land equals true.
And then another if statement, if ready to land and is grounded, then we're going to play dust and
dust fix.
A play.
And we're going to set ready to Land Falls.
And we can wrap it in a function.
There's something like check for land, check for landing.
And let's move well below.
Yeah.
Here.
But we are here to fix something else.
Let's find our functions.
I want to find just button and slide button, and I want to make it unavailable if player is dead.
Because now we accessing these buttons from another place, from the buttons on the UI.
So we need to do if it is dead.
Then return.
Same here.
We can do if sliding or is dead.
Then return.
Okay, let's do it.
Let's see the landing.
Yeah.
There is a dust on landing.
If you feel like it's too much, maybe you can remove it on the double jump or make less emissions so
it's less of them.
It's all up to you and up to your feeling.
All right, let's go to the next video.