What you will learn
In this Unity tutorial, we will learn how to effectively utilize the game engine. Over the tutorial, we will learn how to use the Unity editor interface as well as how to navigate in the scene view. From there, we will learn how to import assets and how to create prefabs. Then we will shape our level even more by adding character controllers, colliders, lights, materials and physics. We will then finish the tutorial by learning how to use scripting in order to make our level interactive.
In this lesson we're going to create fire using particles inside of the Unity game engine. OK, so Unity comes with some pretty neat particles right out of the gate here. And we actually have a fire particle that looks really, really nice. And we're just going to go ahead and use it. So what I want to do is actually import my particles package. So I'm going to right click on my standard assets and I'm going to import package. And I'm going to find the particles and click on that. Now it's going to bring up or Importing Package Wizard here, or dialogue box. And we just want to make sure that we get all of this. So we're going to hit import. And it's going to compile and import all of those assets. And once that's finished, we should see a particles folder inside of standard assets. So here is our particles folder. And you can look at all the different kinds that we actually have. We have dust. We have fire. We have some legacy particles. We have miscellaneous, which hold things like fireworks. We have a light snow, soap bubbles, and sparks. We can bring in smoke. We actually have the source folder, which actually holds all of our shaders and textures and materials and animations. And then we have sparkles and water. And you can use any one of these that you like for your specific project, but in this case we're just going to go ahead and bring in a fire. So I want to use Fire One. And it's as simple as just dragging and dropping it into our scene here. So once we've dropped that particle system into our scene, you'll notice the Fire One has the particles of fire, and then it also has smoke involved with it as well. Now once this has been brought in, you'll see Fire One in your hierarchy. So let's go ahead and move this. And you'll notice that the particles will update and move as we move this here. And what I want to do is actually just kind of bring this fire right over here next to these pods here. Now the particles themselves, this fire particle actually has a couple of children. So let's go ahead and expand the Fire One in our hierarchy. Here you can see that Fire One is actually made up of an inner core, an outer core, and then the actual smoke particles themselves. And we can use our inspector to edit each one of these as we need to. So for example, I'm going to go ahead and take our outer core and I'm going to spread this out a little bit more. I want my fire to be a little bit larger. So let's go ahead and, with that selected, let's go to our inspector and take a look at some of the different options that we have available to us with this particular particle emitter. So first thing that we have is emit. And this is basically saying, do you want this particular part to actually emit any particles? So if you don't like the outer core, you can simply uncheck this and it'll stop emitting those particles. And here you can see those dying, and now they're gone. Now I want to keep those in there. And now we have min size and max size. And this is the actual size of the particles themselves. So what this means is that the minimum size that the particles can go is one and the maximum size of the particles can go to one. Now, we could adjust this and it'll cause what's called a variation. So I'll have some that are the size of one and then I'll have some that are about to in between there, and then all the way up to this 2.79. So if we want something to roll a little bit more and look pretty heavy, we might make the size just a little bit higher. Now the energy is the actual life of the particle. So our minimum energy means that we're going to have some particles that are going to live as long as three. And then we're going to have some that are going to live as long as three as well here. So if we adjust these numbers-- let's say I take the minimum that down to one-- I'm going to have some particles that die after one and then I'm going to have some to just live all the way up to three. So it's going to give us a nice variation. And you can see now we're getting this really nice rolling effect here. So it's adding a little bit more randomness to this fire. Now we have the min and max emission. And this is basically the count of particles that you have. So my object is always going to emit 40 particles, whether it's the minimum or maximum. And again, if you change these numbers, you're going to get a variation in between. So our minimum, we could make this 20. And our max is going to be 40. So we're going to get kind of a random effect if we do this. Now let's talk about our velocity. So we have our world velocity. And our velocity is going to work as-- in the world axis it's going to go either x, y, or z. So if we want these to kind of float up, we actually take our y up a little bit. So as I do this, you'll see that some of my particles begin to flow upward. So that's raging there. And this is kind of the outer core. And these are kind of the flames are going to stay around the bottom. Our inner cores what's actually going to float upward. So I'm going to go ahead and keep my world velocity at zero on this one. Now if I want to spread these out a little bit more, I could go ahead and take my x and y up. So let's go ahead and do two on each one of these. And you'll notice that it's kind of just pushing these flames off in a direction. And what has happened here is it's gone in the x, and I did two in the y is well. So it's averaged those two directions and I get this diagonal flow. So this is how you can actually control things like if fire is popping out of a pipe, there's a gas leak or something like that. Or this could be fire that is actually just raging across a ceiling. Whenever you get a fire that's really, really going, if you'll study that you'll notice that the fire is actually trying to get across the ceiling. And you get this type of effect here. And this is really, really cool. So that's how you can do that. Now this is not exactly the type of fire that I'm looking for, so I might do one on each one of these just to kind of show that it's trying to burn up the paper here as well. Now we have a local velocity, and what this means is it's actually going to use the same type of method or same behavior, just only in the local directions. So if I switch this to local, you would be able to see these moving in a local direction. So let's go ahead and go on down to our random velocity. And this is going to go in any random direction. It's going to go into positive or negative x, positive negative y, or positive negative z. We're going to get kind of a different randomness to our flame here. And we have emitter velocity scale. And if we get too crazy with this number, your particle may break. It's going to go a little bit too fast and it's going to go in some wild directions. So normally I don't like to mess with this really too much. Now we could go through the rest of these, but I kind of feel like we're taking up a lot of time in this lesson just going through each and individual one of these. I really recommend that you experiment with this and get kind of a behavior in your particles that you really want out of your object. So let's go ahead and go down to the particle animator. And you could say that this actually animates a particle. And because this fire just looks so good, I really don't want to mess around with animating the colors or anything like that. So I really like the way it looks and I'm pretty happy with that. But if you wanted to animate color, this would be the place to do it. So let's go ahead and go down to our particle renderer. Here we can see that this is going to cast shadows, it can receive shadows, and then we also have some material options here as well. Now in our materials, we could actually put on several materials. Now in this case, we only have one. If we take this size up it's kind of like acting like a multi sub-object material. So let's go ahead and move down to our actual material itself. So we have a particles additive material and a texture map that looks like a flame here. So that's how we're getting this look here. So that covers quite a bit inside of our particles, and you can begin to experiment with those and begin to understand what each one of these options does. And if you want to know a little bit more, you can usually hover over a selected topic and it'll give you a brief description. And some of these-- let's go to minimum size here. You can see that it's giving you a range, how high you can go with this. All right. So that is particles inside of Unity. And if you want, you can go ahead and play around with this and put as many particles as you want. And just remember that when you start moving these around, you want to make sure you grab the parent and move that parent. You don't want to move just the inner core or just the outer core because then you'll separate the fire particles themselves. So if I wanted to move this and duplicate it, I can just hit control+d and with that main parent selected now I can move this fire to a different position here. So now I've got kind of this crawling fire in another room here. All right, so that wraps up particles inside of Unity. And in our next lesson, we're actually going to get into bringing in a little bit of audio to kind of help with this fire effect.