Important Notice:

As of September 15, 2016, we no longer publish new courses on this website. We encourage you to use your Digital-Tutors credentials to sign in on Pluralsight where you'll find all new creative courses, skill tests and paths, 1:1 mentoring and more.
Creating particle systems
See Details
Joshua Kinney

Pluralsight

Joshua Kinney
In this tutorial, we're going to learn how to add particle systems to our level. All right, so particle systems are a very unique portion of any level that you find. You really can't play a game today without seeing some sort of particle system, whether that be through a spell that your character is casting or rain in a level or fire in a level, things like that. Particle systems are really critical inside video games today. So Unity has a particle system called Shuriken that is very, very robust and great to work with. Very easy and straightforward. So the first thing to do is to go ahead and create a particle system in your level. And this can be done by going to your Hierarchy panel, Create Particle System. Now with this particle system I'm going to go ahead and rename it. And I'm going to call this Dust. And I'm going to go ahead and place this at 0, 0, 0, just to figure out exactly where it's at. And you can see that it's emitting this default particle system. So in order to begin working with particle systems, we need to get the exact type of behavior that we want out of this. Now it's important to remember that particle systems are made up of two elements. The first element is going to be the look, which is going to be your material, and then the second part is going to be your behavior, which is controlled through the particle system parameters. So to see those parameters you must have your particle system selected. And then you need to expand the particle systems. Now this is probably showing up by default. So here you can see that we have several different parameters, or modules, that we can go through to begin working with these particle systems. So the first set of modules that you see here is going to be your basic modules. Your duration, if you want it to be looping, if you want to prewarm, any delay that you need, a lifetime of your particles, the speed of your particles, the starting time, the starting rotation, things like that. So to get started with this we're going to create a very simple particle system just to kind of get you started in experimenting with particles in Unity. So to get started, let's go ahead and resize our overall particle system. And what I want to do is just go ahead and check the shape of a particle system. Now, one thing that I want you to notice with these modules is if you ever see a check box next to one of these modules, that means that one of the parameters in here is active. So if you click on that module, it will expand. And you can see here that we have an active parameter here. So it's not set to 0. So we have our emission and our shape. So I'm going to go ahead and adjust its shape first. I'm going to switch this from a cone to a box. Now I'm going to go ahead and change the shape of this box. And I can modify its shape or size by typing in values. So on our x direction I'm going to type in 160. And I'm going to switch to my top view. So I'm going to click on why and then click on this box in the middle to go to an orthographic view there. And that looks to be wide enough there. And then I'm going to go to my y and I'm going to type in 160 there as well. I'm going to go ahead and pull this down and just try to get this to surround our entire level. Now, I want it to be as close as possible, so I'm going to type 140 in our y there. And that's pretty close. Let's go ahead and do 145. Or I'm sorry, 140 for this one. It's going to be top and bottom. And then we'll do in our x 165. And let's do 170. That should be pretty good. And then our z, we're going to type in 20. So let's go ahead and go back to our perspective view by clicking on this middle box here. And then we're going to switch back to our z direction here. And then we can come in and we can just start to kind of work as normal. So there is our box, Let me go to my x view just to check to make sure my level is in there. OK, we're looking good. All right, so now we have this particle system surrounding our environment, I want to modify the overall behavior of this particle system. So I'm going to collapse shape. And I want it to emit a few more particles than this. So I'm going to say at any time I want 500 particles be on screen at once. So you can see that that begins to really thicken up the particle system. Let's drop that down because that can be way too many for our game to even operate on. So we do want to be careful of that. And the next thing that I want to do is go ahead and tell how many particles I want on the screen at once. So I'm going to go ahead and say let's do 2,000 on that. And you'll see that that will spawn more particles. And let's change the overall motion of this. So up here at the top, whenever we first start our game I want the particles to already be started. So if I stop this and then hit simulate, notice how it takes a little bit of time for these particles to begin going. So if I hit Prewarm, what that will do is if I stop and then simulate, it's already started as if it's been playing for quite some time. So now we have our start lifetime set, all of our particles are going to be living for about five seconds here. And then we have our speed. I'm going to knock that down to about one. I want these to be crawling whenever we start. OK, so very little movement in that. We have our start size. Let's drop that down to about 0.15. We're going to make these very small particles. Now the next thing that I want to do is go ahead and adjust the overall movement of these. So let's go ahead and go down to shape really quickly. And I'm going to adjust this random direction to where they come out at any direction. They're not just going straight up. OK, so there are our particles. We may have to drop down the size of that a little bit. Let's go ahead and go to 10. And just kind of check that, see what we're working with here. Going to go to my x view and then orthographic just so I can see exactly where that's placed. And let's drop this down to five. OK, just so that way we know that those are going to be concentrated on the inside of our environment. OK, so now that I have that we can see that we've got these particles kind of just floating around. And that's looking pretty good. We might adjust the size of those dust particles. We might go to 0.2. And this is the fun thing about particle systems is you just kind of have to play around and begin experimenting with those particle systems and getting the exact behavior that you want out of your game. All right, so now that I have that, let's take a look at a couple of other things really quickly. Let's go into some of these other modules here. These are a little more fun. Things like our size over a lifetime. This is really neat because it allows us to access a curve in here. And if I click on that, on the curve, it brings up the control system right here in our particle system curves. And what I can do is I can say, all right, the size of my particles when they first start, they're going to be half of their starting size. So I'm going to drop that down to 0.5. And then at the end of their life, I want them to be at full strength. So I can come in here and I can begin to adjust that curve. And adjust that any way that I see fit. Now, I have a set of presets here for my curve as well. And this would be great for getting me started. So if I want them to start out at 0, to where they're nonexistent and then they just kind of fade in and grow, we could do that as well. Now in my case, I'm just going to go ahead and leave them at their original size. So I'm going to drop that up at 1.0. And you could even turn this off to deactivate that curve if you don't like the way that's turning out. So let's go to 0.5. We can adjust our curve. OK, get the exact proportions that we want out of our particles. And if that's not working, we'll just turn that off. I'm pretty happy with that shape. So I'm going to leave it just the way it is. OK, so that's how we can use those curves. And you'll see quite a bit that a lot of the different parameters that you have are going to be numbers within a range. And then they're also going to be curves. And curves are really, really fun. I like the way they work here. Let's go to our renderer. And inside of our renderer this is where we can control the overall look of our material. And right now you can see here that the material that's being used is this default particle. So it's this white radio gradient. Let's go ahead and click on that. And this will give us a list of all of our materials that are in our project. And what we want to use is the dust material. And you can find that right up here at the top. This comes with your particles assets. Now if you don't see this, what you'll need to do is go ahead and import the particles package. So you can right click on Assets, Import Package, and then go to Particles. And I already have that in here and you could see that there. And you have several different particle systems that you can bring in and begin to experiment with and kind of explore and find out more about them. So now that I've done this, let's go back to our dust there. And we have our material. And you can see that these dust particles kind of have a little bit of opacity about them, kind of smokey and they're kind of floating in random directions. And so looking really good. I like the way they look so far. And again, you can come in, you can adjust the overall rate of how many particles are in the scene at one time. If it's not thick enough for you, max particles, you can bring this up to 5,000. Now obviously you want to pay attention to how many particles you have because that will begin to become very heavy on your game play itself. So find a good balance between all of those. So a rate of 200 per second and 1,000, that should be pretty good there. So that's looking good. All right, so now that we have discovered how to work with particles on a very basic level, you can come and you can start to experiment with those and create any type of particle system that you would like. All right, so now we have talked about particle systems, in our next lesson what we're going to do is we're going to start jumping into physics. And we're going to start taking objects and making them rigid bodies and making them fall where we can interact with them and things like that. So I'll see you in the next lesson.
In this series of Unity tutorials we are going to learn about the core features in Unity.

We will start out by learning the Unity Interface where we'll talk about the different panels and tools available in the Unity editor. From there we'll learn how to properly export and import assets into Unity. With those assets imported, we'll discuss how to create prefabs that will help us speed up the construction process of our level.

Then we'll learn how to create and apply materials to our level prefabs. Then we'll take our textured prefabs and build a simple game environment. Once the base level has been built, we will talk about adding props and set dressing our level. From there we'll continue full speed by learning how to add lights, particles, and physics objects.

Once we're happy with our level, we'll jump into scripting in Unity. We'll learn how to create a random player spawn, a HUD, item pickups, and so much more. Finally, we'll end the course with how to publish our game to the platform of our choosing.

For an additional learning resource, download your free copy of our Key Game Development Terms Reference Guide and PDF so you can get comfortable with important game dev terminology.
Introduction and Project Overview
1

Introduction and Project Overview

 
01:14
Breaking down the interface
2

Breaking down the interface

 
10:59
File management and project organization
3

File management and project organization

 
10:45
Creating prefabs
4

Creating prefabs

 
10:41
Creating materials
5

Creating materials

 
10:00
Assembling the level
6

Assembling the level

 
08:36
Set dressing the level
7

Set dressing the level

 
14:09
Adding lights
8

Adding lights

 
09:55
Baking lightmaps
9

Baking lightmaps

 
11:32
Creating particle systems
10

Creating particle systems

 
11:19
Working with physics
11

Working with physics

 
09:41
Getting started with scripting
12

Getting started with scripting

 
09:41
Creating the player spawn controller
13

Creating the player spawn controller

 
11:10
Finishing the player spawn controller
14

Finishing the player spawn controller

 
08:12
Creating the game state script
15

Creating the game state script

 
11:46
Scripting the HUD
16

Scripting the HUD

 
13:16
Creating items in Unity
17

Creating items in Unity

 
13:35
Creating the lantern functionality
18

Creating the lantern functionality

 
18:32
Loading levels
19

Loading levels

 
08:08
Publishing our game
20

Publishing our game

 
08:46