Hello again.
In this lecture, we're going to be playing around with particle systems and I'll show you the ins and
outs of how to create your own particle systems.
One kaboom for when we cross the finishing line and the other for when we crash with Barry.
So let's jump in and get started.
Let's start by making some particle effects for when we cross our finish line.
Now the process for creating some particle effects hop over into your hierarchy.
You can right click and create effects particle system and then bump.
There we go.
We see there's some particles being emitted now around the outside of minor have these orange box kind
of things.
That's because the gizmo is showing us the selection outline.
If you find Gizmo at the top of your scene, view the little arrow next to that you can uncheck.
Select an outline, and that will go away.
And then you can see just the particles on their own.
So this is a particle system just sitting within our world.
I'm going to rename this to B, let's see a finish effect.
And then what I'll do is, well, is I'll drag this finish effect underneath finishing line or on top
of finish line so it becomes a child to finish line.
And now this belongs to finish line.
So if I was to click the little icon over near the finish line here and turn that off, you can see
this toggles being able to view things on and off and it will turn off all of the things within the
finish line game object, the, the children underneath it.
Now I want to move it over to where the finish line is going to be.
So while I'm clicked on finish effect, I move, move, move, move, move over to here.
And you can see that's going through the process of zeroing it out.
So I'm actually just going to go 000 for the transform on my finish effect, and that will put it right
in the middle of our finish line.
So I've quickly chucked in a particle effect, but let's have a little look at what's going on here.
So particle systems have an emitter and particles.
The emitter is the thing that we're placing in the world.
That's the thing that has the transform information on it, a certain location.
And then we give behavior to the particles that are being emitted from this emitter.
The particle system itself is a component that gets added to a game object.
So if I jump back into unity, if you have a look at the finish effect, you can see there is a component
here on top of the game object.
If you go right click effects particle system, it will create a new game object and on that it will
automatically add the particle system component.
What I could also do is click on finish line, go to add component and search for particle system and
add a particle system here.
We can do that, but it's not as flexible because if we want to move things around as I did just before,
where's my particle effect go then?
It's much better to have that as a child game object underneath the parent game object and not have
the component right on the parent game object itself.
Because then we can't move the parent and the component independently.
The component that's on this level of game object moves where that game object is going to be.
And then we use modules for controlling the behavior of the particle system.
So the modules, if we click back on our particle effect and open up my component, you see all of this
stuff, here are modules.
If you click on something, click on it, click on it.
It opens up that particular module.
It says a little tick box next to it as we see on emission.
That means we are using the module.
If I click, that emission basically means things getting emitted, so things getting spat out of the
emitter, the particle effects.
So clicking it on means we will be using that module and then we can vary the values within this.
So you see right over time, if I was to increase this to say 100, then it pushes out 100 particles
each second.
That's part of the emission module.
We have the shape module and if I was to click on the shape module here, change it from a cone to say
a sphere.
Then everything will be getting spat out in this round circular kind of pattern.
And the last point of my slide here is each particle is not a game object.
So we have our game object, which is our finish effect game object on which it has a particle system
component.
And we can modify the modules within this component.
But each of these little dots, I'm just going to hit pause on my little menu just here, you see that
comes up whenever you select on your particle effect.
Each of these little dots or particles is not a game object, and it's created in such a way that it's
as efficient as possible to have gazillions of these particles floating around.
So there's some things we can and can't do and can and can't access.
I can't access the transform of this one individual particular particle just here.
I can only access the transform of my emitter and then modify the behavior of the particles as they
get spat out of our emitter.
So click back on play.
And what am I looking to do here?
I'm going to have just a short burst of of like a little fireworks moment, kaboom.
Like that.
So let's have a look at some of the settings here in the main level, the main module in here, the
one that you don't get a choice to turn on and off.
So just at the top, it says Finish Effect, which is the name of our particle system.
The duration is how long we are going to say turn on the particle effect when we trigger it in our code.
So if I stop here at the moment, you can see that this is looping and we know that because the looping
checkbox is turned on.
So it's saying Run for 5 seconds, this is a duration.
And then when they're 5 seconds has ended well.
Just loop start again from the start.
So I'm going to turn off looping and I can change the duration down to 1/2 click on play and you see
we get 1/2 worth of bursts, 1/2 worth of particles being emitted.
So that's getting closer to what I'm looking for, for my kind of celebration.
You cross the finish line, that kind of burst quick effect.
I'm going to put this down to say, I don't know, 0.2.
And just between you and me, I haven't planned what I'm going to do with my particle system here.
I'm just jumping in and winging it, which is nearly always the way that I create particle systems.
I play around with the values a little bit more or they use a little bit less of that until I get it
to the point where I like it.
So if I click play here, kaboom, there's a little bit of a a particle explosion.
That's great.
Okay.
What are the next numbers we need to look for in here?
Well, the start lifetime is going to determine how long each particle lives for.
And you can see it's on 5 seconds at the moment.
So these particles, while I was jabbering away, their lasted for 5 seconds and then blinked out.
I want to have them a little bit lower than that, probably around about a second.
So if I put it to one on start lifetime and then when I click on play, we get 1/2 where they stay alive
one and then stop.
But I want a little bit of variation.
I want some of them to last a little bit longer, some to last a little bit shorter.
So just to the right of our value here, you see the little dropdown arrow thingy.
Click on that.
I'm going a choice of a couple of things here.
I'm going to choose random between two constants.
What's that mean?
Well, a constant is going to be a fixed number.
So at the moment, start lifetime is seeing random between five and one.
It's a little bit backwards.
It's kind of between 1/2 and 5/2.
I'm going to make this between 0.2 seconds and 1/2.
That's fine.
We'll see how that goes.
Click Play.
If you watch closely, some of the particles blink out very quickly and some last longer.
That means there's going to be a randomness.
Each particle will be assigned a random value from 0.2 to 1, so it could be 0.6, 0.5 or 0.8 that it
will last for that it will stay alive for the next thing is start speed.
So at the moment, we get this gentle kind of light coming out of our finish line.
Let's change that as well.
So instead of five, let's do it random between two constants to get some variation in there.
We'll do it between five and 100 to see what happens.
Bam!
Okay, that's going to shoot these things off way further and way faster.
Do I want them to go that far?
Probably not.
And what's really interesting is the distance that the particle effect travels is a function of its
lifetime and its speed.
So if something is going to go at 100 and last for 1/2, it's going to go maximum speed for maximum
amount of time.
So I'm going to reduce the overall variation there.
I don't want these things going.
Oh, so far.
So what do I want to do?
Reduce the speed all the time?
Probably have them last longer.
Sorry, last shorter.
So 0.5 there.
So they're not going quite as far.
They're not living quite as long.
There's still some of them shooting off a long way.
So I'm going to change this to point three and maybe this to 50.
So like I say, it's just a lot of messing around to see how things go.
Yeah, and that looks pretty good.
Okay.
What do we want to look at next?
Well, we already briefly looked at emission.
I want to turn the emission up.
Now that we've turned the duration down to 0.2, that means we're only going to get 0.2 of a second's
worth of emission.
So we're going to get 0.2 of this 100, which, if my mathematics doesn't elude me, is probably 20
particles that are being spat out.
So you see in there, I'm going to play and then pause very quickly.
There's around about 20 particles being spat out.
So if I increase this to say 500 and then go play broom, that's probably more like 100 particles getting
sprayed out.
Okay, so that's looking the general shape I'm after in terms of the emission.
But speaking of shape, we can change the shape of the particles, see how they're kind of these soft,
kind of fluffy little particle balls.
Here, if you scroll all the way down in your particle system, click on Renderer.
We can change in here the material that's being used, click the selector and you should have some options
in here where you can change to the sprite default, which is a square shape.
It's just a straight up square block.
And I like that because it gives it a little bit more texture.
I think when you play, it's instead of these little fairy ball things, it's a good chunky block and
I think that fits with the style of our game.
Okay, now I'm not super happy with the color.
It's very snow ish in color, but when we cross over our finish line, it's red.
So we should probably have some red in there.
If we have a look at all the way up to the top, you see our start color.
If we click the little select next to that, I can once again get some variation.
I can have a gradient random between two colors rain in between two gradients.
I'm going to choose random between two colors.
The first color I will have I think is white to say, yeah, in the snow.
And the second color, if I click on the white here, I'm going to change it to a red.
So when I click on play, we should get all the colors between white and red, including a bunch of
pinks in there saying, Kaboom, we've crossed the finishing line.
You can play around with all these values.
You're not going to break anything and see what happens.
The other one I tend to play around with is noise.
So if we click on noise, you can see that it's going to apply some sort of wobbly ness to it.
So if I click play, you're not seeing wobbling ness yet.
If I increase the strength.
That's a ten.
Click on play.
Then you get some worldliness.
It's hard to see when it's going so fast.
What can we do about that?
You see the playback speed here?
If I put this to 0.2, that will show us.
A little bit of that wobbly ness.
Yeah, at that slower speed.
What about 0.7 play?
Okay, you know what?
It actually looks a bit better when these things aren't going quite so crazy fast.
Let me put this back up to one from a little bit too quick.
I'm going to go up here now and change my start speed, probably from 5 to 50 to 5 to 25.
We'll see how that looks.
Well, look, okay, I'm happy with that.
When you cross the finish line just a little bit about explosion, not too bad.
Okay.
So we've created one particle system here together.
My challenge for you is to go ahead and create a second particle effect that we can trigger when the
player crashes.
So for now, just create the particle effect.
We're not going to trigger it until the next lecture, pause the video, create a second particle effect.
And when you're back, I will show you how I'll go about creating mine.
And just a little tip.
If you're going to want a cheat, you could go and click on this one and duplicate it, control D,
rename it, put it in a different spot, etc. And then you could modify what we've created already.
That's a little sneaky tip for you there if you want to do that, but there's a challenge to take that
on.
See you back here when you're done.
Okay.
So I am actually going to do my sneaky tip.
I'm going to control D and I'm going to change this to B crash effect.
Now it's totally in the wrong spot.
Where do we want to trigger a particle effect?
When we crash, we want to trigger it on the player.
So let's go and drag out crash effect underneath Barre Bump that should open it up.
So we have got crash effect in there and we need to crash effect.
We need to set its position to 000 so that it's right on top of Barre here, maybe even pop it on top
of his head.
There we go.
And you can see these little shuriken or ninja stars, if you will, to show that's us using the particle
system.
When I click on play, boom, that's firing out of Barry's head.
I'd like to have it probably in front, I think rather than behind, you can do whatever you want.
So how do we do that in front?
Well, scroll all the way down to Renderer and find.
Where are we?
It's a little bit hidden in here.
So you see order in layer.
It's the same order and layer we've played around with before.
I'll put this at 20 because I think Barry's currently at ten, so click on play.
Okay, now that's in front of his face, like boom.
So we see when he crashes, we see the particle effect more than we see him, which is fine now he's
going to be crashing into the snow.
So I want it to be snow sort of color.
So click on the color, change it to Bluey kind of thing for one of them.
See how that looks?
Kaboom.
When you crashes now they're a little bit too big when he smashes his head.
I don't need them that big.
So the other thing I didn't show you before, we can change the start size.
So you start size is currently one.
Let's make a start size of 0.3 and see how that feels.
Well, okay, just little dots flying out.
So I'm going to do a randomness here.
Random between two constants.
I'm going to do it from one to point three.
I prefer to do things the other way around so I can see it logically.
0.3 to Shall I make it one?
I make it 0.8, I think kaboom.
So there's some stuff that's going to spray out of his head.
It looks a little bit too much like the other one, the finish line one.
So we'll make it a little bit smaller.
I don't think his brain spraying quite that far.
So let us change the start lifetime down to point two, you know, maybe 0.1 end point to boom.
Just a quick little crash.
There we go.
So I've created two particle effects, one for when we crash, kaboom.
One for when we're on the finishing line and we cross finishing line capacity.
We're ready in the next lecture to hook those up and to trigger them in our code.
So I'll see you in the next lecture.