Hello and welcome to another episode in the Godot Basics tutorial series in this episode, we will be taking a look at the particle2D node in order to create a fire effect. So in your scene, Tab, go ahead and press the plus button to create a new node. You can either search for it or type it in the search bar. And if you type it out, you should notice under the node to the particle, to the node, go ahead and press the button. And that's all it takes in order to create a particle 2D node onto your scene tab.
Now, you'll notice here an error sign, and that's just letting you know that there is, in fact, no material, basically you're particles material. And so in order to alleviate this error, go ahead into the inspector tab with the particle to denote highlighted under processed material. Go ahead and click that. Once you've processed material, you're going to see a section called material. Go ahead and press that. You should see some options. Go ahead and press new particles material in order to create your particles material and therefore alleviate the error message.
And now, as you can see here on the screen, if I were to scroll.
You can sort of see that even though we haven't set the texture, that because the texture file is in fact empty, it goes ahead and creates more tiny squares for us and it's dropping. And that's because we have the gravity property set. To basically 98 on the positive y axis, which means we are going down and even though we can't count it because our amount is set to eight or eight individual particles alive at the same time.
So after this, let's go ahead and set our texture. So if you go to the inspector tab and click on Texture's, you should see that our texture's empty. And that's fine because we're going to add an image as the texture. So I'm going to go ahead and upload a white podgy file onto our file system one moment. Why do that? So I went ahead and uploaded a white square image. So if you can see here, it's basically this image now, as you can see here, this is our texture file.
And really you can use any page you file you want, any shape, any size, any form. The recommended color to add is white.
First, let's go ahead and drag the white square onto our texture to set the texture. And now when I turn on emitting, you can see that we're dropping due to gravity. Now, I'm going to go ahead and move this note towards the bottom so we can see the effects that we take in after. And I'm going to leave the omitting to on so we can see the shape and form that we take. And this is basically game programming. Game programming is when you have a go. In this case, we want to make fire, but we don't know exactly how to start.
And so through iteration and through a lot of time, we'll eventually get to our result. And the more experience you have, the faster you get to your result because you know how to do it. Basically, if you've done it once, you can do it a thousand times. But in this case, we want to make fire. So we're going to leave the emitting on so we can see its effect. As you can see here, it's dropping. We don't want that. So we come to processed materials and we edit the values inside. So first, we don't want gravity. And so in the gravity tab, we're going to set this to zero.
And you can see that no gravity is being applied. We do have, in fact, eight particles being created. And if we look at the time, Toub, you can see that the lifetime is set to one. And so all eight particles are life for one second each. However, we would like this thing to move up like fire. If we go to the initial velocity and we set the velocity, we can set it to something. And if we increase it, we can see that it's moving further and further to the right. And that's because by default, our direction is set to one on the excess.
Now let's go ahead and set the X value to zero and the Y value to negative one. And you should see that it starts moving up. Now, there is a little bit of a spread, and so if you don't want that spread to happen, you can set that to zero and notice how we go up. In this case, we do want a little spread. And so I'm going to set it to ten for now. We don't know what that may be later. Now, next, the image is too big, and because we're creating fire, we need it to be as realistic as possible.
So the smaller the image, the better. Now, normally you'd like to import the texture image to the size you'd like in your game. However, to illustrate the purpose of the scale. I purposely made the white squares big now. Next, let's go ahead and change the size of our images. And so in this case, I'm going to set it to one point four excuse me, zero point five. And that looks a little better.
Is there a point to looks a little better?
I'm going to leave it at zero point three for now, we'll see how that plays out next. I'm going to set a scale curved to do that. Just go ahead. And under the skill curve section, if you click on that, you get new curve texture. And if you click on the newly created texture, you get this curve graph. So here we have our newly created curve. You can see here that there's a line straight at the top. If it's a little small, that's OK. In the drop down menu, you can go ahead and press edit. And now we have this bigger curve. And so, as you can see here, we can change the way our scaling behaves.
So as you can see here, we start small because we set our curve to the x y coordinate value zero zero and it curves in size or the size grows based on the curve you see here in our curve property, the final value being one one. So it becomes as big as the original square size or in this case, zero point three, because that's the value we set it to. But we don't want it to start small and grow big. So instead we're going to make it big and eventually grow smaller.
So that looks a little better. You can start seeing it starting to look like fire, but this bottom is sort of throwing me off. And so we need to create a new point. So if you click on the graph and select that point, you can add a point and modify. And so you can see here, if we zoom in because we start at zero, our scale is at zero at the origin, it grows to a size and then it sort of dies off. But we don't want that. And so we're going to change just until it starts looking like a flame for us.
And so that looks quite about right for me. So I'm going to head back and we're going to change some other values. So in this case, we have our fire starting to take form. However, it's looking a little too square. And so to round off our square, we need it to spin. In order to spin, we need to set an angular velocity. And so if we just change this, you can see everything starting to spin. And so now it's really starting to look a little unique, a little more like fire are squares are starting at the same angled position.
And so in order to change its starting position, we go to the angle tab and we can set it to any value in this case. We're going to set it to three hundred sixty. That represents three hundred sixty degrees. You'll see nothing has changed. However, down here, an angle random if we set that value to one. We're saying that from the values of zero degrees through three hundred and sixty degrees, place our square image at a random position, but it's still looking a little off. And so let's change the amounts a little bit.
And so if we come to a amount, we're going to do three hundred. We'll see how that plays out. And so you're starting to see now that it's starting to really look like fire. But let's write down a little bit. OK, great. So now we're starting to get a little fire. And so you can see that just by playing with the settings, we can sort of play around with our image looks. I'm going to go ahead and move this. Now, if we really zoom out, you're going to see that it really starts to look a little bit like fire. And so the problem is it's too big to alleviate this.
We can lower down the initial velocity. And so you'll see in real time that it's starting to die down a little bit, our fire, and so we can play around with a few other values. Tangent, you'll start to see how that looks. And so you can see our fire starting to look like it's being pushed by wind. If we have one hundred, we have negative one hundred. You can see it's moving to the left so you can play around with tangential acceleration. And so if we were to actually have this in code, we could actually just move or tangential acceleration to sort of get our fire to wane a little bit.
I'm just going to leave this at zero. So we have other values we can play with as well. For example, trail, as you can see here, if we set the value to 11, starting to change its value. Let's go ahead and set this to five. So after playing around with the trail, I'm not liking any of the values. Maybe, too, just a little bit, but not really. So I'm going to leave this at one. But again, this is basically game programming. You just play around with the values and so you get something you like. We're going to finish this off. And so I'm going to go under color. And from here we can actually change the color of our fire.
I'm going to set this to wait to get the fire to really look like fire. We need to start at a color, perhaps orange, and ended on another color, perhaps white to simulate smoke is what I'm thinking in my mind. So let's go ahead and go through color red. We're going to pick a new gradient texture. Notice how it's black. That's OK, because under a gradient, we're going to create a new gradient. And so, as you can see here, we're ranging from black to white. And so you can sort of see that there's this color popping up like white is being pushed up.
So you can imagine once we change the colors, this is going to look really nice. Now to change the colors, all you have to do is simply click on the little square and to the right you're going to see your color. So go ahead and click that. You'll be shown a screen. In this case, we want to start off with orange. So maybe that kind of orange and towards the end we would like white. So I'm going to leave that alone. However, we would like a little bit of red. And so let me click here in the gradient. And when you click inside the gradient, you are going to create this new point. So keep that in mind.
These rectangles you see here are color points. And so in this case, I've created a new color point and it takes whatever color is at that point. However, I would like to get a little darker and towards here I'm going to create a new point again and I'm going to click on the square. But this time I'd like it red so we can really get. Show that fiery effect and maybe come back here and change this color.
To something else so we can.
Sort of see an effect happening and so I'm going to leave it like this. So if we zoom out, you'll start to see it's starting to really look like fire. Now, if you notice here, our fire has color. It has the right movement, but it's a little static at the top. And so we can change this by changing the initial velocity, but not touching the velocity variable, but instead the velocity, randomness variable. And so at least we can get the fire to sort of exit at the top at different speeds.
And so you can see here that we sort of get a nice little fire effect and you can just sort of play around with that until you get an effect you really like. And so in this case, I'm going to leave at a zero point or as close as I can get to it. And so our fire starting to really pop out towards the top. Now, if you press play, you're going to see our fire effect on the screen. And so we sort of got the effect we want. Leslie, you'll notice that the fire tip just doesn't look right. And so in this case, let's go ahead and change the linear acceleration.
So in this case, I'm going to increase linear acceleration so you can sort of see that the fire sort of ending higher and what it is. So, for example, this is zero. This is one hundred. And then back to zero, and so the fire sort of dies down a little bit. So in this case, I'm going to set it to one hundred, but I'm going to set the value to one. And so now our fire tips are starting and ending at different positions. So we're starting to really get that look and feel of fire. And basically, this is it. This is game programming in programming, again, is just iteration.
You keep doing something until it has this look and feel. We can keep going on to see the results. And it's a matter of fact, I'd encourage you to even change your textures. So in this case, we started with a square. But what happens if you use the triangle or a circle? If you have Photoshop, you can even use different custom brush settings like a spray. And so you can just spray around your canvas in white, export it with a transparent background. And now you have this funky looking, smoky like texture that you can use as well.
And so you can see where I'm going with this. And that is that through iteration, you can make your fire look and feel like fire. And so in this case, I tried my best to get squares to look and feel like a fire. And I'm sure we can smooth that out really well. If we played around with maybe if we make it really fast, the angular velocity to seven, 20. Now, that feels a little better. Maybe if we make a random. And so, again, as you can see, just through iteration, we can get our particle 2D to look and feel a certain way.
Well, I had fun making this episode, just messing around with the settings to get the look and feel of fire. It's OK if you couldn't see or look at the settings because I'm going to upload this to get help. So please feel free to take a look at the GitHub project file to play around with the particles 2D node that emits fire. And again, I just want to remind you that game programming is iteration in this case. I spent about, I would say twenty minutes before editing, just playing around with some of the settings, finding a setting I liked and then bringing it back to you.
But in reality, making fire could take five hours, 10 hours, maybe even a week if you really wanted to get the look and feel and behavior of fire for your game. And so, again, game programming is all about iteration until you are satisfied. Well, that's all I have for you in this episode. Thank you so much for joining me. Thank you for clicking the like button and thank you for clicking the subscribe button. If you have any comments or questions, please feel free to leave them in the comments section down below. I look forward to seeing you in the next episode.
Have an amazing day.