Transcripts
1. Introduction: All right. Welcome, everyone. In this course, we're going to go ahead and use the Goda engine here and do some scripting using a language called G D script or go Doubt script. And we're going to take that. We're going to create a platformer. Now, while creating this platform, we're gonna learn how to create tile sets. We're gonna learn about collision. We're gonna learn how to create a G y for a game, how to connect everything, have it all communicating back and forth and triggering things between different scripts. We're going to have animations. We're gonna have different screens. We're gonna have custom buttons, backgrounds. We're gonna have enemies that have some basic AI to them so that they don't just stand there. You're gonna be able to you not only get hurt when you touch them, but be able to jump on top of them, just like you would in a Mario game. We're gonna have wind conditions. Were gonna have particle effects going on. We're gonna have collectibles, all different things. And I think you're gonna add music into our levels. So if you want to go learn how you can create a platformer, by all means, sign up to this course. I hope you enjoy yourself. And I hope you learn a lot
2. Where and How To Get GoDot: All right, everyone. Our first step here is to actually install the go, not engine. So to do that, you can do it one of two ways. Technically three, we're gonna go over two of them here, and that is to go to the goat out website itself. Goto engine dot org's and head on over to the download tab up here. There we go. And they have the standard and mono version. We're just gonna be using the standard version here. So you go ahead and grab the 64 or 32 bit and make sure that you grab it for the appropriate platform. Appear up top. Now, if you get it from the site here, you are not gonna have the templates installed in order to export your project. So to do that, you can also go ahead and grab the export templates right down here with standard person. And if you want to get this through another way, you can get it through steam ever that you just come on here. You're free button. Here. Go ahead and download it and your templates. And that will already be Prince Stone for you. All right, Let's we want the next video and get this engine open right on up
3. Creating The Project and Template Setup: all right. When you first open up, go down, you're gonna be greeted to a window like this. Now, if you get it through steam, you're gonna have all of these a bunch of different demos in here. And if not, if you got this the website, you can find them all within the templates here, if not most from you should be able to. So the first thing where the news we're going to create a new project here and we're gonna go ahead and named, uh, let's go with It's got the awesome platformer. I'm gonna go ahead and leave mine right here, my documents. But if you want to, But that somewhere else see totally Canseco and hip crowds and locate where you want to put it. And I'm just gonna hit, create boulder. Now you can use either render here but myself. I'm gonna use the 3.0 version here of hoping Geo, I'm just gonna hate, create and edit. All right, so now that our project is open were greeted with this screen here. Now the first thing we're going to dio is actually get our templates installed in case you guys got your from the website and not Rammstein. So income right out of here to our editor. We're going to go down to manage export templates, and you can either hit download here and then click this link and your download will automatically start. Or if you downloaded the file from the website, you can install from Bio and just select that and it'll install it so you can go ahead and get your templates either of those two ways, if you got it off the website, all right, that will do it for this video and in the next one will go ahead and start jumping into creating our game.
4. Importing Assets: All right, everyone in this video, we're gonna go ahead and import our assets. So after you download our included assets, when we get ours from from two different places here we will be getting some of our audio here from sound image dot org's This is where we have somewhere music. So if you would like to browse on here or find some from somewhere else that's finding up to you. But the included one is from sound image here and our right and that, and some of our audio is from Kenny acids here. Now, can he has some great assets, Um, and with a lot of them that are provided for 100% for free. Now, when you have those downloaded, go ahead, unzipped. Um, and you'll get your folder here. Let's go ahead and open up. Worry file manager down here. So I'm going to right click on the R ES folder down here and go toe opening a file manager . And now this is this is basically our game right here so far, which does not consist of mine. No, I'm just gonna go ahead and copy over everything in our resource folder. They included assets and just paste them on in here into our game. Porter. Now I've already gone ahead and organize these. So you take a look at audio, got this broken down to announcer music and you I and then we look a texture. This is broken down into enemies items, other player and tiles already. And we're gonna need one more folder for this and we're going to call this one screw and we'll make one more or scenes. It is important to have proper folder structure to keep your project clean, organized and always know where everything is. Now we just go ahead and click back into gold, and they will begin importing everything. Now, if it stops responding for a moment, that's no problem. Don't worry about it. Just let it do its thing. And there you go. It's complete. Now we have everything down in here which is perfect in our voluntary beans and obviously is empty. Same script and our textures down here. All right, so that's it's a simple is that we've gone ahead with imported Ah, what the assets we're gonna need here
5. Creating The Player and Movement: All right, So in our first video here, we wouldn't go ahead and start setting up our game. We're gonna create our player and start getting some of our movements in. So we're gonna create a two D seen and we have a no to d um, you know it. Go ahead. How do we want? Go ahead and change this. So just right, click and change tight and we're gonna use a cinematic body to D. Now, if we take a look down below, we can see this is a cinematic body to denote and a a physics body is basically something that calculates visits. So a Kinnah Matic body to d actually takes input from what would be our player. So whenever the player pressed the button, we can have it react in some way. There are other physics bodies goes like this. Look at physics body to tease. Here we have a static body which does not move, so this would act like a wall. A rigid body was still calculates our physics and can be moved when hit. So if you've ever played a game with, say, a bowl on the table and you hit the bowl and it flies off the table. Oh, uh, maybe something like soccer or football here in Europe. And you walk into the ball and the ball booze, something that would be more like a rigid body and then Kinnah Matic body and the situation would be a player. And so So we're gonna go ahead and set up a kingdom attic body to D. I'm gonna go ahead and change the name of this two player, and you'll see we have this little yellow triangle here. Now, what this does is it tells us that we're missing things, and in this case, this note has no sheep. You can't collide or interact with anything, so we need a collision shape or a collision polygon with this for us, we're going to go ahead. And before we add that we're going to click this little plus up here and we're gonna add and animated scrape, we could use a regular straight, but we're going to have our animated. We're just going to use this click back on player it plus, and we're gonna go ahead and add that collision. Now our collision shape needs some kind of collision. However, we don't know what sighs or anything to make this because we cannot see our player currently. So in order to start this, we're gonna click on our animated straight. We're going to click on the far right here in the Inspector. Worse, the Springs is going to quit and hit new Sprite brains. And then quick that again, I'm gonna rename our default here to idle. And now this is where you're going to be able to decide which sprites you want to use for your player. We see we're gonna have down in our textures player. We have five different options here, so you can pick any of the ones any of these that you want. They all have the same animations in here. I think I'm gonna choose. Um, Let's see. I think I'm just gonna choose the default mail here. So if you want to use female, you can or the adventurer soldier zombies perfectly up to you. Let's see. So I'm just going to select the I don't frame here. I'm just gonna drag that right on in to our bottom section here and let that go. And now we have are a little player. Now we know how big our coalition box needs to be. So in click on collision shape to D over to the right, select a shape and I'm going to use a rectangle. Now, you just grab these little orange handles here on the side and you can just hold the melt until they get to about the size of our player. See well that a little more and then pull it up here of this up. And that's fine. No, if you wanted to cut it off down here, floor down a little more like this or even bring it in here and just cover the body, that's perfectly fine. And it's your game. If you feel that is something that you would like to dio, you can certainly do that. I'm gonna go somewhere in between these two options, and now we have collision sheep and we have our littlest right here with our idol. Now we can click on player and we can begin adding a script to our player here, says Quick on Player. Click this little script with a green plus i p at the top, and we can go ahead and name this player dot G d is gonna do this in Judy script. It inherits from the cinematic body to D. We're not going to use any templates. However, we're gonna quick little border and change the path. If you want to make sure this goes into our scripts and then had create all right, we don't need any of these at the top. We can remove that. Actually, we can. I keep that Pirmin here, and you can go ahead and read that that a ready function? It's called as soon as as soon as they see this note or this scene is loaded up. So as soon as the player loads, whatever's inside of this ready function is going to happen, then passed. Of course, this waste he allows it to basically allows us to leave it empty without it causing it to ever out or anything. Now, we also have the physics process down here, which I'm going to uncommon. Just hold control and crash que on your keyboard, and this is basically something that's going to be called every single frame of your game. So I'm just gonna go ahead and for that, and this is what we have now In order to start doing some movement with our player, we're gonna need some variables, one of these being our velocity. And that's what's gonna be equal to a vector to 00 Another way of typing. This would be vector to zero. Either those will or just fine. I'm just going to remove that one off of the end. They're both exactly the same thing, and we can set our speed. I'm just gonna go ahead and create a variable costs speed. And let's equal that, too. I don't know. Let's say 50 for now. All right, so let's go ahead and create a here into our process function. Really check for F our players pressing certain buttons, then make this happen. So by default you could use the you I buns, which is going to be the arrow keys on the keyboard. However, if you want to create your own input buttons such as if you want to use wst or something else, Um, this does also support controller. If you wanted to use that, I'm sculpting the top here Project Project settings input map, And this is where you can edit all of these and add new ones. So for myself, it's gonna go ahead and those and I'm just going to create a new one and just call it left . And right now, to assign buttons to these, I'm just gonna go and hit this loss icon. I'm gonna press Kik someone cube or cotton if you would like, use your controller us like joy button or Joy Axis, depending on what you're looking for. One key, and I'm just gonna press the button on the keyboard. So left, I'm going to press a and OK and her right, we're gonna hit de and hit. OK, all right. Now in our process function here, we're gonna go ahead and do it. Input that if action breath, There we go. Um, Capitals and lower case is very important here, and we need to give it an argument of a string. So inside of quotation marks, we're gonna put the button name we're gonna start with left, and then we also want to make sure that we're not pressing the other button currency and not input is action press. And in here we're just gonna pull it right, and then we're gonna we end that off with our Colon on the end here, which is what is yelling at us for at the bottom. You know, we could go ahead, delete pass. Now what we want to happen is we wanna move in the left direction. So if you remember back in math class or looking at graphs X is gonna be our horizontal plane And why is our vertical? So if we're looking at this at A to D. X is going to be going left and right and why is gonna be going up and down removing left or right that we need to adjust our X? So we're just gonna set velocity dot X equal to now, we've already set up our quickly moving at the top with speed. And if we're gonna move left, we're moving in the negative direction. So we're just going to dio negative speed. All right, let's go ahead and save that save seen as save it into our scenes. And this is our our players. Now we have a player, but we need to actually have a way to move them or a place to move him. Let's go ahead and quick. There are little plus sign at the top here and hit Judy, and we're going to need something for a player to move on some kind of ground for now. So to do this, we're just going to use the basic sprite that comes with it. So we're going to select icon dot p and G down here, which is just gonna be the gold out symbol. I'm just going to drag it out and drop it in our scene and let's just wretched across there we go. And inside of this, we're gonna scene and add and make this a static body, grab our icon and drag it into it. Select our static body. It needs a collision, See? And we're just gonna select a box or a and what does pull that out? And there we go. That will do. All right. Selecting our no. Two d up here at the top. We're gonna snout select this chain icon or this link, and that's going to allow us to instance in our player. So after we click that, you can see that we see scenes, Flash Player, we're gonna select that and pick open. And now our player is in the scene. This says move him down here. Save our scene, and we're going to call this level one. All right, Now, let's go ahead and just hit the play button in the top. Right? Select ants like a level one for our main senior. All right, Now, if we hit left, our character should move. Laugh. Oh, 11 mistake here. Um, it is important not to forget. We need to do a movie and slide here. We're gonna pass in our velocity and let's try that again. There we go. We can see that when we hit our left button, they move left. Now they're gonna consistently move left because we haven't told it what to do if we're not pressing any buttons. So to get him to stop moving, we simply just add in an else statement. It just says velocity X equals zero. Now, when we stop pressing, left is going to stop moving just like that. Now, if you want him to move faster or slower, just come on up here. And a justice speed. If we change this from 5500 we're gonna see is going to move a lot quicker what he did before. Okay, so now that we have that I'm going to throw a challenge to you. Go ahead and create our input section to move our character to the right. Go ahead and do that and I'll see you in just a moment. Who have how to do that? Incan double check with our You know how we how we do that here. All right, To do this, we're just going to go ahead and create another if statement, however, we're going to create this one as an l f. And also so to do that, it's just e l i f. Now, if you didn't know that, that's fine. If you're trying to just do a normal if statement, you notice that you'll be able to move to the right. What, you won't actually able to move to the left anymore. And this is why we need to do in else it like this. Everything else will remain pretty well the same. So I left and board that is action pressed right and not input is actually press left. Velocity dot x equals Swede. Now we can go ahead and test that and you see, we could move right and we could move left. And when we stop pressing either button, we stopped moving. And you noticed, since we did the and not in port with the opposite direction, you know, it's that we pressed. Both of them were not gonna move. However, if we let go of one, they're gonna move in that direction. All right, So that covers our basic movement. We can now move our player up, and us are not up and down, but left and right. And we have our little I don't look here. And we've been on a lot in this video. In the next one, we're gonna go ahead and we're gonna give our Blair The ability to jump is right now. Just moving left and right isn't going to make for a very bond platformer. All right, I'll go ahead and I will see in the next video
6. Jumping: are at everyone in this video. We're gonna go ahead and give our player of the ability to actually jump. So for this, we're gonna head on into our scripts, goto our player, and we're gonna need another variable four hour jump speed, and I'm gonna big mine. All caps here. There we go. And I'm gonna set mine too. Mm, Let's go. 1500. We'll see how that does. And I'm also going to create a constant called up and that will equal a vector to zero minus one. Now, again, you could do vector to dot up it would be the exact same thing. And in our movement slide, we're not gonna have velocity for first argument. And our 2nd 1 is going to be already. Now, before we get moving with this, we can go ahead and take all of this important in a separate bunk. And for that, we could just call that one or create one called function moved. I'm just going to take all of this, cut it and just paste it right on down here. That's backers in one. Perfect. Now for our function. I'm actually gonna change this for me. Process to a physics process. There's just underscore physics at the beginning. There. So it is now underscore physics underscore process. Cool. So you are jumping. We're simply going to do and input not is action crashed, and I've gotta fix my eye at the beginning. Here should be a lower case. And for action. This is just gonna be now. I don't currently have a jump button, so I need to create one action. The button will be space bar. Okay, now. All right. So if our jump button is pressed, we're going to simply just adjust our velocity, and we're gonna change the white. Remember, why is our vertical velocity dot Why? And we have said that too minus equals or intercepted two equals negative jump screen. Either way, we'll have the same result now, we don't want our player to be able to, you know, let's take a look at that first before I get on that No, cannot move. And why's that in our physics process here? We have to call an hour move function there ago. Just like so. Okay, let's go back in. We could move left. We could move right, and we can jump. We could jump very, very high. Uh huh. The problem is, is we're not actually coming down, and we can actually were touched on that. In the next video. Some pronouns gonna adjust my jump speed to something much lower, like 50. Now, you see, we hit jump, and we just keep going up. And now to fix that, we simply just have to do add one secondary condition in here. And that is we're also gonna check for and is on floor. Now. That is why we needed our up arguments of that. The engine knows which weighs up. No, no, it can tell whether or not we're actually on the floor. So we take a look room. You see, we have this tiny little baby, John, we're not actually on the floor if you want him down. And now he's touching. And now we didn't jump, and he goes up and I was no longer touching it. But of course, and we'll have any gravity is going to keep loading up and up. So in our next video, we'll go ahead and add in some gravity to pull him right back down to the Earth year
7. Gravity: All right, everyone. We're going to apply gravity so that our character comes back down after jumping. So I just simply taken our code here and put it inside of a function called Jump. And I've got another constant here called gravity. And I've got that set to 100. Just go ahead and create a function and call it. Apply gravity and inside of our physics process, we're gonna go ahead and make sure we call it now inside of our apply gravity. All we have to do is the simply check and power player is on the floor or not. They're gonna dio yeah, for not if in, if not, is on floor. Then we're gonna take the velocity. Not why? Because remember, the why is the up and down the vertical I was gonna plus equals gravity and that's it. Now if we go ahead and hit play, she wouldn't go laugh. Go right. We can jump. And now we actually come back down so you can go ahead and edit these numbers. However you feel to something that you feel seems right or looks good to you, it's over. That's really all we need to do in order to apply gravity here. All right, now we have a player that could move left and right and can go ahead and jump around. All right, I'll see you guys in the next video.
8. Single and Double Jump: All right. Welcome. One. In this video, we're gonna go over how to give ourselves a single trump or a double job, because, as you see here, we can just continuously keep jumping up completely out of screen as high as we want. And that's not really gonna be acceptable in a platform for here. So we take a look at our script. First thing I did is I set this, too. Is action just pressed instead of his actual press? That way, the button access repressed. Whereas if you have it as it's actually pressed, the player would be able to just hold it down and you would be able to repeatedly just keep jumping. No, just a small note there. So to do our jumping, we're going to create a variable called jump count and set it to zero. Now, down here in our jump, we're gonna have if input is actually just crest jump and we'll have a second condition. So and jump count is less than one. Then we have our velocity dot Why equals negative jump speed or you couldn't also right its velocity dot y minus equals jump street. Um, then right after that, we will have our jump count, equal jump count plus one. And then we will have an a left statement here. LF is on here, jump count equals zero. This way our jump counter will actually reset. And that way we can jump is if we don't let it reset, Then we will never be able to jump again in our game. If you want to have some kind of puzzle platform where you can only have I'm saying maybe three jumps for that level, and that's it. Then you will not need to reset. So with our jump count being less than one, take a look. And has he seen about having kind of Christ jump? We only have a single jump. All right, so I'm gonna task you with the option of chases from being a single jump to allowing the player to do a double jump. And once you think you got that figured out, come on back and I'll show you my solution first. All right, welcome back. And the easiest solution for this is to just come in to our condition here. And you could either change this one to a to or you can change it from less than 12 less than or equal to one. We have less than or equal to one. We have our double jump works. Fine. And if we chose to do it as less than to that will also work. That's fine. Exactly the same. And doesn't the two easiest ways to change it from a single jump to a double. Now, if you went ahead and went about this a different way, then that is perfectly fine. As long as you came across to the same result. There have a only having a double. Not three, not one, but he If you figure this out, give yourself a pat on the back. Yeah, you didn't. And no worries. No problem. Uh, if you feel like you need you re watch or understand a little bar, you can always feel free to ask questions. And that will do it for this video. Seeing the next guys
9. Animating the Player: are right. Everyone in this video, we're going a go ahead and animate our player. So for this one, we can go ahead and just create a another function down here phone, and we'll call this one enemy. And for now, we'll just hit pass, and we'll come back to it in a moment. In our player scene on our animation player, we're gonna go ahead and create another animation and calling that what? Yeah, we just got walk and we'll create another one called, So we'll do jump first, as that'll be the simplest year textures player select Whichever one used and jump is one frame here. Perfect. And we're walk and you'll see we have to frame, sure, so just selecting both and dragged them in. And if we hit, play will be able to actually take a look. No animation with you if you want cassette playing two on and you can take something looking to see that now we can adjust our speed FBS down here, and we want to make sure it stays loop so we have five. Let's take a look at 10. See how that works. 10 Seems a little too quick. Seven maybe six. Find something that you're happy with. I mean, even five could still work if you wanted to stay with that. Just find something that you're comfortable with. Or good speed. I think I'm gonna set mine too. Six, You say we had pretty full cycles. Now, back in our script or enemy function here, we're going to go ahead and, yeah, our motion why is less than zero? So we're checking busy. If we're jumping, then we're going to go ahead and get our animation player here. So dollar sign, animated scrape, and we're just gonna hit way. And then inside of here, we get a strength. So quotation marks and we're gonna name the animation. In this case, it is jump. And I'm just gonna go ahead and double check. Yes, I had for me. It's jump with a capital J Perfect, not motion. I'm sorry, Velocity. If velocity dot why is less than zero? All right. So if we go ahead and add animate, appear to our visit process, we hit play. When we jump, we should see I need to set that. But that's happening automatically. Would go ahead and just change animation here to idle. You see, when we jumped our animation changes. And, of course, it doesn't go back to normal when we land, we'll get back to that when we address the more. Or actually, you know, we could go ahead and set our idol right now for that simple, which is doing else and then our animated scrape play. And I don't Yeah, And that's what makes that. Yeah. Now we have them jumping perfectly fine. All right, Perfect. So what we now need is to determine whether or not we're going left or right and to play those animation. So you've seen how we set our jump here. Now, I'm gonna give you a challenge to go ahead and see if you can play the our animation for going right. And we're going left now for hand will be using the same animation on both of them. That's why I just call it What? But go ahead. See if you can figure that out. Do your best. And once you think you've got appeared out or you get stuck and come on back and I'll show you how I go about doing this. All right. Welcome back. So in here we're just gonna do, and I left statement Elia, Velocity got X is not equal zero and velocity God is greater than zero. Then what we're gonna do in here is we're gonna walk to the right, which is our default walk animation. Either we're going to go ahead and get our animate. It's great way, and that's just going to be And then we're gonna have another one here. Velocity not equal zero, and velocity is less than zero. And we're gonna play the same animation here. How ever there is one difference Because we don't want it to walk the same we wanted Teoh. I'm going the other way. So an easy way to save on a little bit of resources by having Mawr textures or more straight for whatever then need is we can simply take our animated scrape and just do went I'm gonna flip it horizontally and was set that to true Now just to be save Uhm I'm going to go ahead and set our animated scribe, uh, flip horizontal to false here. Whenever we're going to the right just to make sure gonna actually switches back and forth without any issues here. Let's go ahead and take a look and we could go right. We could go laugh and weaken, jump. And when we jump, we're facing the right direction. All right, now we have our player all animated, regardless off which straight you decided to go with here. And creating animations or making new animations is just a ZZ as that. So if you want to go ahead and mess around, make your own little animations and great your buttons to make things happen, you can definitely go ahead and do that. Feel free to experiment and explore a little bit, but for now, that's all the animations re need.
10. Tilesets: All right, everyone welcoming in this video, we're going to create a tile set so that we can actually start building a level. So this is kind of, I guess, neat and works. It's a very boring, very boring platforms having this one block to run back and forth with. So let's go ahead and start making a title set. So to do this, we're gonna have to go ahead and create a new scene. It's gonna be a two d seen and we'll go ahead and save it. And our scenes Azaz pile set, folks, it's not typing there. There we go. Ohio set. Ah, let's go where we'll go. Tile sent one and saving. Okay. Now, to do this, you can use whichever color version you would like together. Whichever color variant opening under textures, tiles making is the blue, brown, green or yellow. You can take a look at those right here, decide which ones you want. And personally, I think I'm gonna go ahead and use the blue ones. So I was going to select all of them and then just dragged him into the scene here. Now you're gonna see all of them get created here got 27 of them. Now I'm gonna go through and decide which ones I want to keep and which ones I want to get rid of. And to do that, I'm just gonna simply drag him out and line them up like this. I see which of these are going to want to trying to side here. I think the ones that don't have a transparent background are the ones I'm just going to get pretty and just not use. We're going to go through, take a look at all of him here, Se. I'm thinking there this year. Okay? So, based off of these, I think I'm going to get rid of all of these ones, not use them. If you want to go ahead and use these ones and your own projects, you can totally go and do that. There's nothing wrong with it but myself. I'm going to get rid of these ones. And to that I just hit. I just clicked and dragged over him to select them off. And I just hit the delete key on the keyboard. Okay, Now, let's go ahead and organize. How many do we have here? What we got one too. Here, five, six, seven, eight will do eight in a room. So we've got 18 tiles. In my case, if you're using more economically, do that or if you want to go ahead and use the other colors as well. You can definitely do that if you want to put it all into one tile set. But I've got all of mine started out here and we're just going to go through all of these and the same way So I'm going to start with Let's see, I start with this one just because I can show you two examples of doing this. So the name of your tiles here is what's gonna show up inside of our tile map. So just keep that in mind if you end up with something with weird names in the future eso we're gonna click on in my case Tile blue 22 we're going to click add, we're gonna add a static body to D and our yellow triangle says that we need a collision shape. We're gonna go ahead and add a coalition shape in this case and in our inspector over on the right. We're gonna go ahead and select a rectangle. I was gonna pull that out and match it as best as we can. Okay, that looks good. Now our next one here. Hi. Oh, Blue 23. We're gonna start with the same run at a static body duty, and that needs a seat. Now, this time I'm not gonna add a c a polygon to D, as are a collision polygon TD. Now, this works different in the fact that we could make any shape that we would like this. So I'm just going to go ahead and click in this corner, this corner, this one here and then back where we started and have the benefit to this is especially if you want to make a game that's pixel perfect. You can click on that and you can actually drag it around and set it to exactly where you want it to be. They see, if we come down were slightly off here, and that is because this corner, it's not exact. And that's a bit Just pull it down there. Personally, I like using the Holly Gagne over the collision shape, but the collision shape is much easier and allows you to go much quicker. Yeah, this one is off a bit. Well, that in And there we go. So for something like a shapely this, we're gonna have around edges and angles and things like that that we can't get from a standard sheet, you're gonna need to use the collision polygon. And for something that more square, like this piece here, you can go ahead and just use a probably gone for. So go ahead. And probably that same step through album at a static body to D and then add a collision to it. And once you get that, we'll move on to the next step. Okay? Once you have all of your tiles here with their collisions, then we're gonna go ahead and a scene we're gonna save. Seen as savor over our old one now that we have all of this done. Oh, sorry. Not safety notice. Just save seen. Here we go. All right, Now what we're gonna do, we're gonna come down to the scene convert to select tile set. Now, we can put this in quite a few different places. We're going to go under textures Kyle's, and then I'm going to create a new holder. We'll call this one, I'll sets. All right. And now we can name this, and I'm gonna call this blue platform. Kind of set and hit Save must use valid extent. Okay, let's see what we're saving as ah t R E s cool. Now here, over here in our main Seen we could go ahead and delete this static body that we were using before. Just delete it. Get it out of there now. Weaken. Go ahead. And finally add our time set to us. We're gonna add into it, and it's actually a node called hyo map. So go ahead and select that. And then over on the right side here, we can see we have an empty slot. And then in the Inspector, we have a section called Title Setting. It says empty. Go ahead and click on that and we can hit load. And now, director, So right to our tile sets of textures. Tiles Kyle set and there's glue platform time set. Open that up. And now you see, we have all of our pieces here. Now we have to do is just click and we start building with it. It's a simple is I'm gonna go ahead and undo. If you want to delete one, you just hover over it and right click on it should remove it. Why does it all right? We need to have the same tile selected. Here we go. So it's going to create a just a basic little over here just to get ourselves going. Let's see. Go ahead. Put a gap in there. Do that place that piece in there. Let's see. We have a piece of their another piece of here. Um, you have one piece there? I don't know. Um, you'll have put this triangle off camera there, because why not? I guess. And let's go ahead. Jump in CFR collision is working, and it it is our jump we kept on these ones. Here we go. Perfect. They're tiles that should be working just fine. So you can go ahead and take that and go ahead and build yourself a level. If you would like to Well, im gon I just fell right off So course in this instance that should cause it in your game Unless you have a more level underneath for now. There we go. We have a title set, we have, ah, collision to everything. And now we can easily just come on in and start painting out our see however we would like . So go ahead and creature so a level if you need more space, go ahead and back up and feel pretty built outside of our blue area outside of this blue rectangle and go ahead and build yourself a level and I'll see in the next video when I've got mine, Bill.
11. Camera That Follows The Player: All right. Welcome back, everyone. And in this video, we're going to go over. How do you create a camera that follows the player now and go about? This is actually extremely simple. We don't have to do much to actually accomplish this. So just head on over to your players, seen so either loaded up double click it in your holders or click this little I can hear that says open an editor. So to do this, we're just gonna hadn't hit this close button. We're going to select the camera to D, and then over in our inspector, we will hit current. Now, we can make some changes here in limit. So if you want a limited so that the camera can only go to a certain point, you can set that there. I have set smoothing the speed. You're offset so you can go ahead and adjust this however you would like. So, as you can see here, our camera is being completely off sent from our center point here. Well, we just reset that that you placed right back in the center. And if we wanted, we could set like this. And then the cameras always to the far right, our player or we just leave it here and then it's always right in the center again. You can go ahead and change pretty much anything over here on the side that you would like for limit. I don't really need anything there, um, at sea, do you? Let's try sets were living on and sure relieve this screen up. Five. Let's just go ahead and jump in so you can see how the camera follows with this. And all we did is we can't smoothie on using and steep on speed. Now, with that off, this is, as you can see, how it would look. It'll be perfectly with us the entire time, so it's up to you. If you want smoothing with yours or he would not use smoothing with your camera, it's gonna be again up to your own preference and how you want to design your game. Now gravity is really strong, so now if you have her level, you can go back and you could start editing your gravity. You can edit your jump speed, which just in your how you're able to actually jump. You go ahead back through and start tweaking those numbers. And now that we have our cameras set up to go with our player, we're pretty much set for this. Our player is pretty much done at this point until we start adding anything else that needs toe, be added to it and link up with things like you are, such as things like help. So that'll do it for this video, you know, see guest in the next one.
12. Invisible Barriers: All right, everybody welcome. And in this video, I'm just gonna quickly show you how to make and invisible barrier. That way, if you need to block the player from a certain area, then you can easily do that or in the case for a platformer, if you don't want to build a wall behind them, um, this will also prevent them from just walking off backwards and just right on going right off the map. Now do this. It's very simple. We just got to go ahead and add in a static body and give it a collision sheet that shape. We're going to select a rectangle, and we're just gonna increase the height of it. If you want to increase the with a little bit, you can. And the end here for edges how far the player will be able to go. So if you want to set it right to the edge of the screen, you can easily do that just like so, Or if you want to be. You know, maybe in more like this. You can also do that. I'm gonna set mine to the edge of my screen. Since I've set my camera to the limit of right here so I can't go any more left than what is currently set. So now that we're going game, you know I can't go that way. And I want to make sure that it's also high enough that you clearly cannot jump over, which is gonna vary by game, whether or not you have jumping. If it's a platformer, you probably dio it wasn't easy. Just go like this and I don't want to block anything down here necessarily. You know, maybe I will rebel block this entire side off for these platforms and we can just go like that now when I go ahead and play, I can't go that way. I can't jump over it. I can't continue off that way, and I can't go that way. So that's just a quick and easy way that you could go ahead and create an invisible barrier for your game.
13. Gravity Fixes: All right, everyone in this video, we're going to go ahead and I'm gonna show you. How do you knicks this floating mechanic here? Whenever you're player hits his head, how is just still gonna float along the top there? And I'm gonna show you how to fix the speed here when you're following? Because for you, it might get quicker, Quicker. As you see here, the more the player false. It's just gonna quicker and quicker, which is a little strange. So we're gonna lose that consistency, which is a bit of a shame, but But we can easily fix that Here. So we're gonna do, is and our gravity function here. We're gonna go ahead and share. Yeah, is on ceiling. But I was when you spell right and we're gonna go ahead and set the velocity, why plus equals gravity and for myself, I personally like it. I want to do times two that way. Once you hit your head, you just come straight down immediately. And since this game has a double jump mechanic, if you would like your player to not be able to jump after they bumped their head, then you can also just go ahead and modify the jump count to reach your natural. In that way, they cannot jump. Now, if you want your player to be able to do their second jump, then you do not need this line. Be all you need is the velocity, not why plus equals gravity Times two Now for our other our last section here we can simply just doing it is on year and we adjust our velocity. I've got why and said it equal to zero and that will stop are falling, increasing and sweet every time. Let's go ahead and jump in and you can see here. Once we hit our head, we can't. We just come straight back down immediately and because we're setting our jump counter to our match boom, when we hit our head, we cannot hit our second jump there after hitting her head. Now, of course, if you wanted to again allow your player to do a second jump or if you only have one jump, then you don't need that line, and you should see what stood to a second job. So it's up to you how you would like to design that aspect of your game. As for the falling you see, it's going to be just is consistent every time. It's not going to speed up every time we found. Now I'm going to go ahead in. Use this line, though, that we win. You get your head. You can't jump again. That's it. That's how we fixed. Ah, two issues that we now come across with our gravity now that we actually have a level to start testing things with. And if you guys are curious on the numbers I've settled on, I've settled on my jump speed being 800 with my gravity being set out 50. All right, I'll see you guys in the next video.
14. Good Practice: Okay, guys, in this video, we're just gonna go quickly, go over some, um, better practice from best practice when doing some of your code. And to do that simply when we're creating variables, you can just tell the anti and exactly what kind of variable it is. So for something like velocity here, we can tell it that it's a vector to than if we try to put anything else here that's not a vector to It is going to get upset. It's going to spit on error, and it's going to tell us that something is wrong, which, if we try to do something like that for a Swede, I put a vector to for a screed. Obviously, that would completely break things that would cause so many things toe break down. So doing this or just help help produce any chance of pulling any errors and problems in the future. So to do that, you just take your variable right after the name, do a colon space and then the type so it can be in vector to every I NT for integer. You can do float if it's afloat, which means it's a decimal number. You could also do Bull B O l and this eyes going to tell you the engine that this has toe be either true or false. It can't be anything else. So that's just some of the better practices that you should get used to and should be doing structure projects. So I went ahead and added this in here before we, you know, start adding, like way too many things and become so much of a hassle this way. You've only got a few things to go ahead and that you can change and edit that right now. And I'll see you guys in the next video.
15. Collectibles and Points: All right, everyone in this figure, we're going to go over how to quickly make a collectible and add points every time we pick this thing up. So go on into your script folder and just right, click it new script. You can leave it empty and just name it mobile and double click it and go ahead and add a variable in here. Just call points. And now, in order for us to set this as a global, we're going to go up into project project settings, go to the auto load tab and her path here is going to select your script, the global script and for the name you can just leave that as global and hit the add button . Now that we have that, we need something that we can actually collect. So for that we can create a new scene that is a to t seen. I'm gonna rename this to Jewell, and we're going to need a few things. We're going to need a sprite. We're going to need an animation player. We're going to need particle to tease, cause we're gonna make it sparkle and well, should we need running to detect collisions So we're gonna need an area to D. And inside of that, we will need a collision. She start from the top or a sprite. You can go down into your textures, did dio items, and I'm going to use the green. Jewell, you can use any color and any item you want here. Are you just gonna take that? Click it and drag it into your inspector into the empty texture section. Now, for the size, I'm gonna go ahead and double that. That looks a little better when it's actually in game. Are particles here? We're going to click on that next, and we're gonna goto texture and inside of our textures folder your CFX and sparkling particle just regular into the texture section side of our inspector and now open process materials. And we're gonna show you a new particle material, just like so Click on that emission shape. Let's go with a spear. Ah, let's see. Drawing No. How about time for lifetime? And when achieved, 1 to 0.1. But they're really quick now because it's still going in a very small sphere. You can't really tell. So what I'm going to do is increased my spear radius to about 30. And now it looks something like that for my collision shape inside of our area to D, which is going to a rectangle and make it about size of our Jim here, you that. And now we've got our animation player. We can go look at the animation button at the bottom click that do new name it obtained. Change our length at the end of the timeline to Cedar 0.5 and you notice we have keys all in our inspector toe animate anything. We're going to go to the top note here are root note quick on it for a transformed. We're gonna put a key frame right here at the beginning that create and then, ah, the sirah 0.3. I'm gonna change these down to zero and do another keeper in, and that's gonna pretty well allow it to just shrink down very quickly already. Now, for a jewel, we can go ahead and attach a script. We can call it Jule collectible. It creates we're going to click on our animation player. Click on no drip aside, Inspector, and we're gonna send a signal animation finished and connect that and for area to d, We're gonna also send a signal body entered to the fuel. And let's start with animation. When the animation is finished, we're simply just gonna queue free the object two Simple Is that now for the body when a body enter if we want to check if the body that entered is our player. So we're going to do if player in body not name. There we go. Do this. So if player is in, what if whatever physics body enters the area? If the name of that note is Claire, this is what we're going to dio. So in this case, we're gonna get our global points because you want to increase that. So global God points eso If you change your name from global to something else, you're going to use that name got your variable and we're just going to say equals mobile dot points plus one. And to make sure that works, we do prints global points. And then what else we're gonna do is we're gonna play our animation animation player play obtained that shrinks down, And just to make sure we don't run into any bugs with being able to collect it twice. We're going Teoh our collision shape here. And just to say what? No USO collision shape two d r two d dot disabled equals. True. It's like so All right, go ahead and save that in our scenes. That's gonna be our Jewell scene. And now, in level one, we can go ahead and instance in our Jewell and we'll go ahead and place thes all over our map as many as you need and I'll do one more or our little test here. Ah, but this one of right there, let's go ahead and jump in. Boom. We got one and I missed that one. That's unfortunate. One to you can see our points going up down here in our output. And as we get him, they shrink down and disappear. So we got to be sparkly. We got a little animation for it to disappear. We're increasing our points. We have everything that we need for our little collectible, so you can go ahead and make any changes that as you want, you can change properties to your particle effect. If you would like making it look completely unique, if you will, you can do whatever you want in there, and that's how we create a little collectible that we can pick up and then increase a stat for behind. Whether it's something you want to be collected when your game. So you can have keep track of how many of the player has over how many there are in total. Or if it's something like this, we're going to keep track of points for each one collected or whatever. And once we got that, that's the basics of being able to pick up anything and making something happen when the player does. So after that, go ahead. I'll see you in the next video.
16. Creating The Enemy: are at everyone. Welcome back. And in this video, we're gonna go over creating an enemy or a game. We're not gonna go over any of the AI or anything, but we're gonna get everything set up in this video, and then we'll go over the scripting in the next one. So we're gonna create a new scene. It's gonna be a two D seen right click our root note here. We can actually change that tight to a Kinnah Matic body to D, and we're going to give it a name of Walker. Now, we're gonna have to add a few things here. Let's go where we needed And, um, it it's right. We need to area two days for this for what we're doing. And each of those needs to have a collision seat. Our walker here are root note. It's gonna need a collision shape as well. We're going to need a ray cast to D and make sure in the instruction that you turn that on . I don't know why it's disabled by default. Um, that all we're gonna need, um I believe so. If I'm missing anything, then once this will cover that in the next video, we start going through the scripts, so let's start animated spray. Go to the inspector frames like new straight rain. Click that and we're going to get We don't really need Idol, but we could have want who put Neidl and we'll have one for dead so you can use which ever enemies you would like but textures enemies and go and select whichever. But we're gonna use enemy walking one for idol one and two with walking animation and her dead we're going to use and we walking five. So these are what we're using here. Perfect. We can set that on Idol animation toe Idol. Five frames is just fine with that. Both of these now our collision shape. That's part of our walker. How do we want to set that? Yeah, not yet. Let's go to our recast to D. We can change the cast to down to 25. What if I shouldn't find and then just go ahead and move it over to the right? Like so All right now we have area to D. We have two of them were going to set 12 called player damage and we're gonna rename the other one to enemy damage. Do not when you're renaming these, do not use any spaces, or you will cause some severe problems later down the line. Uh, so our player damage. Let's give that a box a rectangle sheet. Um, before we do, you I'm actually gonna adjust the scale to 1.5 times the size. It's just my grayscale to already seems better. Ontario and I can adjust my box accordingly. And those would be like that. And now for my enemy damage, I'm gonna make that a rectangle and notice I did not go all the way up top, and that's because that's where my enemy damage here is going to go. We just shrink that down. Well, that just like that. So now we basically set it up. So when the player we're gonna set up from that when the player jumps on top, the enemy dies. And if they bump into him from the sides, the player is going to get hurt. And then our last collision shape here, which is part of the our root note here. This is actually before visits. So he said that as a rectangle we were just make that down here for that. Bottom of the feet is the bottom that we walk from. And for with you would just want to make it bigger, then our top bigger than the player damage. I'm sorry. Bigger than the enemy. Damage was smaller. And with then the player damage that should work. Fine. So when you've got that set up, it should look something like this. And if you got all this set, then we should be ready. Teoh, jump in and start looking at our script.
17. Enemy AI: All right, everyone in this video, we're going to give our little walker guy here some ai. So let's go ahead and click on our route note and at a script, make sure you put that in our script folder and I'm just gonna need mine. Walker A I we can leave it to be empty. That's fine. And here we go. We're just gonna go ahead and just to hide right on in. But first, we do need some signals. We need a saint, a former player damage area. But we need to connect a body entered. We need to connect a body entered for enemy damage and the need We do not need that. This should be good. All right, So in stabbing to our script, So to start off, we're going to need some variables or some constants when he constant Swede, which is an integer we're gonna make it 80 have another constant gravity. It's an inter gear. We'll make it 50 just like we have with the player. Another constant of which is a vector to equal to Better to got. And we did a variable for our velocity which will be a vector to equal to for now as a depot vector to zero. We won't need a direction for this. So we know which way they're moving direction, which is an integer in this case, we're just going to use one and negative one, and then we're actually gonna need a bully in here. Core is dead just like that. And that's what we're gonna need to get ourselves started. Four functions. We're gonna need a process. One year, we just it past. For now, we're going to need a function for death, and we're gonna need a function for movement. Okay? And once you have all of that set, we have all of our bases here ready to go. So what, We're actually gonna jump over to our player it real quick for creating a function to functions. We want to create function hurt. And that's just gonna print a string that says how I have seen her and we're going to create another function for enemy jump. And that's basically just gonna be like our like, our jump here. So it's gonna adjust our velocity. Why equals minus jump speed? That's all we're going to do for that. And those are the two things we need to step in our player here. Now we can come right back to our walker. Hey, I hear and we can get all of this set. So going from top to bottom, we need for process. We're gonna do movement. And we wanted to movement, birth or death. Ah, let's set up the death burst because that's gonna be the quickest one. So is within F statement. If is dead is equal to true Surfer enemy has died. Oh, it's hard we're not doing if they were setting it too True. We're also going to take our animated Sprite and we're gonna play an animation. Which one? Our dead animation. We're then going to take a our collision sheet two D and set disabled Sri. That way our player can walk through instead of having to jump up and over our enemy here because remember, that's our physics one. And then we're going to get our enemy damage collision. And we're going to disable that because FB looks if our enemy is dead, we don't need them to die over and over. It's just going to cause an issue, possibly an infinite loop. And we're gonna do the same thing for player damage because we don't want the player to get hurt after the enemies already dead. And in last, we need to set our velocity not X 20 So he stops moving and we could stop here. And if you want the bodies to remain on screen, you can. But if you want them to disappear, we can just do a Q free. But I'm going to do something a little in the middle. I'm actually gonna have a timer. So we're gonna wait about five seconds, and then the body will disappear. So to do that, we just use yield and inside of that for argument, we use get free dot create timer and inside the crate timer argument, we set a time in second Somebody's five seconds. And then outside of our argument, would you comma and you see this pop up, we're gonna use time out. So basically, we're gonna create a timer, and we're gonna wait for the timer to finish, which we've set to five seconds, and then we're gonna delete this object. So taking a quick run through our death argument here, we're gonna set is dead too true. We're gonna play the dead animation. We wanted to save our collision boxes so nobody can get hurt. And the player can just walk through after the enemy has been killed. We're gonna stop the enemy from being able to move. Once they die, they don't keep moving. We're gonna wait five seconds and then we're gonna delete the item. The item being the enemy in this case. Okay, uh, let's go. Let's do our player damaging enemy damage That could be really quick ones. So for a player damage if the player enters the body. So let's just like we did before with our collectible. If player in body the name do this, which what you can do from here, she could actually call a function on that body. And that is exactly what we're gonna do is we're going to body don't. And in this case, we're going to call the function hurt that we created. So we were do it just like that. And now, for when enemy takes damage, we're gonna start with the same thing. Yeah, player in body name. Right. Your body. Uh, and this We're going to get our enemy jump function. So once we jump on top of the enemy, we're gonna Clyde with the enemy. And we're gonna bounce back up in the air, just like with Mario. And we're gonna call the death function, Um, our sprite here, our enemy. And I actually think I want to change this from five seconds to one second. And if you want to use fraction C one these, like maybe 1.5 2nd you can definitely do that. But that is the majority of our script done. The movement is going to be long, Not super complicated, just long. But I'm gonna go ahead and show you what we have here. So if we just go to level one, I'm gonna instance in our walker and just set him right up here and let's take a look right now he doesn't move, But if we touch him from the side, you can see in the council out. I have been hurt. So this is where the player would take damage off we jump on top of him. You see, we bounce up and he dies. Simple is that we didn't catch the animal. The change in animation. There we go. so we bounce off of him, and then that's it. So now we have a way that we can kill the enemy and ah, way for the enemy. Taxi! Hurt us. Now let's program his movement and his A I we have a way for him to die. Let's have a move around. So he's not as interesting? Sorry. So he's not as boring and make him or interesting. Okay, now, this is gonna be the big one. So the first thing we need to check is if they are dead, because obviously, if the enemy is dead, he can't move. So we're gonna make sure we're gonna check and make sure that the enemy is not dead. Make sure that they are alive, and then we're gonna do adjust our velocity, not X. So our horizontal movement, that's gonna be equal to our speed, times direction. So this is great. She gonna set our X t to be a positive or negative and the positive and negative especially gonna tell them whether they're moving left or if they're moving right now, we can check if direction is equal to one. So if it's a positive in dollar animation, Sprite don't flip. Horizontal is false else looks else. The animated scrape not flip horizontal equals True. So what this is basically going to do is if our creature are Walker is moving to the right , which would be a positive direction. Then our scribe is not going to be flipped. And once they turn around and start going left, we're gonna flip it so that it looks like they're walking the proper direction instead of walking backwards. So that's what we have set there. However, we do need to actually play our animation, the animated straight Doc play. And this is just gonna be walk like that right now. They walk left and right. But if we ever have something fall to the ground or however how one might end up falling, we actually need to have our gravity applied to it set. They actually fall the velocity dot why plus equals our gravity. And now we can do our move and slide velocity. Uh, so now what we have is we have gravity. If there in the air, this way, they can actually fall down to ever. They're going. We're playing the walk animation. We're deciding if it should be flipped or not based on whether or not they're going left or right, and we're basically able to tell them which direction is up. So we know whether it's on the ground. If it's a ceiling, if it's hitting a wall, whatever. And we're almost done with our basic enemy A I hear. So we're going to check if is on wall. So if our missile base is gonna allow us to check if our enemy is bumped into anything, whether it's another another enemy or a wall from your tile set or whatever. And this is what we want to happen, which is our direction equals direction times negative one. So this is gonna set it. If it's positive, which is one, then if it bumps into something we're gonna times by negative one, which is gonna do one times negative one, which results in a negative. So that's gonna basically tell it to flip directions. Now go in the other direction. And if it's going in the other direction, that's we've been in the negative direction that we negative one times negative one, which account to positive, which will tell it to flip back in the other way. And not only do we need that too much, but we also need our ray cast to move as well. So we're just gonna get recast to be position dot Exe times equals minus one. That's great. We're going to do the same thing. It's just gonna flip that based on the direction. So our recast either on the left or right of handy on which way are Walker is going and it's always going to keep it in front. And why do we need that? Because we also need to check if our Ray calf is colliding or not. We needed sex with colliding or not. And if it is not colliding, then we need our enemy to turn around. So what this is going to do? What we're checking here is if we're going to come back here, If this arrow is not touching the ground, then our enemy is going to turn around so he doesn't walk off the edge. And so if you want your enemy to be able to walk off the edge than you, do not need this section here where we check if Ray cast is caught. If race caste is colliding here. But if you want to be able to turn and not walk off of the edge, then we're going to do the exact same thing here. Direction equals direction, times minus one and same with our recast doc position Got X. Times equals minus one just like that. So who? That was a doozy. Let's go ahead and go over this. So we have our speed, our speed, gravity and up direction. We have our velocity, the direction that we're walking and whether or not our enemy is dead. Our process, which is running every frame, is running our movement so that our enemies constantly moving. We have a function called death. So when our enemy is killed, is dead is changing too true that they don't walk anymore. We're gonna play the dead animation going to disable the collision boxes. So, um, the enemy can't get killed more than once in some weird bug. So the player can't be killed from touching the dead body and disabling its collision blocks of the player can walk past the dead enemy without having to jump over his body, were then setting our velocity to zero so they cannot walk anywhere the body would just stop moving instead of continuously sliding that direction. We are telling our script to wait one second and then or delete the enemy to free up resources so we don't cause leg from a lot of enemies. And now, when we move on to our movement or function here, so we're going to check if our enemy is still alive. So if is dead false, we're gonna set our X velocity is gonna be our speed. Times are direction. So that's gonna come out either being positive or negative, which controls whether or not removing left or right and then our section here based on our direction. So based on whether we're moving left or right, we're gonna flip the sprite so that he's always moving forward. Our next line here is we're playing our walking animation that we're not just standing there and gliding by. We're applying gravity in case they get knocked off an edge or if you want to drop enemies from above or whatever else, and we have our moving slide so we know which way is up, and we need that so we can check whether or not our enemy is on a wall which are next section here, and that's basically just checking if it bumps into a tile with collision. If it bumps into another enemy, then we're going to change our direction. And instead of moving right, if we bump into something, we're going to turn left. And if we're talking to something that way, we're gonna turn right and we're just gonna move our ray cast in that other direction as well. That way is always in front of her and yes, of our enemy. So we can constantly detect what's in front of it underneath, which is where we're checking right here. If it is colliding and if it's no longer colliding with the floor, then we're gonna do the same thing here and just flip it everything to go in the other direction. Almost done. Then we have our player damage when the body enters. So the body being our player for this, where player is going to take damage which, if we look back at our scrape, is gonna be the sides of our enemy. So if the player touches the sides, we're going to call the heart function on our player, which at the moment just prints a string that says How I have been hurt and we have a function for the enemies damage when the But when the player enters what is going to be on top of the head? So if the player is what enters the top, we're going to do our call the enemy jump function on our player, which is gonna bounce us back up in the air. And we're going to call death on our enemy here, which again comes back up here to the first function. Covered who? That was a big one. So let's go ahead and take a look at it. We go into our level. We have one enemy here. Go ahead, raise him up and let him fall on down. And let's go ahead instance in another one. There he is. And we just put this one right here and let's go ahead and take a look at them so that I could see they walk when they bump into things or detect that there on the ledge. They turn around immediately. Like I said, three acting a little looks a little strange. Let's not drop them and just moving down here they bump into each other, they turn around, and when we jump on top of them, boot dead and put dead and you can see it says how I have been hurt because I had touched thes side of them. So you can see we now have enemy movement, the player he had heard from touching the sides. The player can kill the enemy by jumping on top of them. The player bounces off the top, just like in Mario. And now we have our simple little basic AI enemy with the way that we can collect points. And that's great. You now know some of the basics into creating a basic AI like some classic platforms again like we would see in a game like Mario. All right, so with that, I'll see you guys in the next video.
18. Player LIves: All right, everyone in this video, we're gonna go ahead and give our player some lives. That way you can take X amount of hits before they actually dying. Every time they get hit, their health is actually gonna decrease. So to do this, let's go ahead and jump right into our script. And we're going to need a variable called Lives here variable lives. And that's just gonna be in integer. And we'll set our default to three lives. So s so we're gonna have to take three hits before we die here. Now, when we get hit by our enemy Oh, my mistake. I'm putting that in the wrong script. I'm giving that to our walker. I want to put that with our players here. Well, our lives and equals Mariko. Now, whenever our our walker here touches our player, it calls the heart function. So this is where we're gonna put our, um, every time we lose the hell this where it's gonna go. So simply, we're gonna do if lives air greater, then zero Dr. Greater than zero. Then what we do? We take our lives and minus one. The lives equal lives minus one and then we will. We can go ahead and say, Yeah, lives less than or equal to zero. And for now, this will have our game over seen play out. But for now, we'll just say print. You have died and that should be all we really need to do this. So let's go ahead and take a look. And just to make sure this working, we'll go ahead and we'll print out our lives. Okay, so let's take a look. Um boom, Boom. We've lost two lives and zero you have died. So really, it's as simple as I'm gonna go ahead and move that up here. Fact we're gonna called that before we even do anything. And then we can also call it. You can see the last one and they were dead. So really, it's as simple as that force to set it. If you really want that in our and are ready function here, he can go ahead and set the amount of lives that you want to play her to have when he loads in. So if you always want the player to have start with three, no matter what, you can come in and you can always go like, let's go hang like that and that will set it as soon as we loaded. And instead of just going around, we go ahead and print it. You see, we come out with a three run out the back when our numbers seem to have gone really were down there. But the important thing is it does work. So if we go in one to three and I'm dead so this the output is getting a little weird, but it works. And at the end of the day, so that's all we have to do. And now we have a lives system in place. I'm gonna go ahead and take this out of my ready function. I'm just because I don't feel a need to have it myself. And I'll just pull out my prints treatments. But that's all we need right now. And when we implement our game over, we'll go ahead and put it down here
19. Game Over: All right, everyone in this video, we're gonna go ahead and just touch on the G Y a little bit. And that is just a great our game over screen. So first off running to create a new scene, we're going to use other note and weaken. Just use a What do we want to use? Still a canvas layer for this? And in this, we're gonna go ahead and do a have a dialogue box, and this will be our game over. Lay out anchors, and we'll send that to the center. Now, in our pop of dialogue, we will create a a text rich text label Just simply going to read game over. We're gonna add two buttons, one can play again and no one called Game over. These are not came over. Quit and just go ahead and put that in. Cool. That is not what I wanted. Go ahead and called. I didn't like that ankle, so that'll do. For for now. Now you want to make this Ah, lot fast here. Feel free to do so for now. We're gonna go our canvas layer at the top are root note and at a script to it move its location into our scripts folder and we'll call it G Y and create. We're gonna need the ready function, and we're gonna need a function that we're going to call up the I can smell update underscore G Y at least the two functions that are gonna pretty much call everything here. So to start off with, we're going to go ahead and actually add this into a group. Here we go. So in our ready, we're gonna do add to group and this takes a string as an argument, and this is gonna be the group. In this case, we're gonna make the group G y. And if you want to do this another way, you actually could have clicked on node of here and clicked on groups and added it this way rather than doing it in the script. But since we're already in here, figure 2 may swell. But I just thought I'd let you know. You can also do it that way. So when we update our G, why, we're actually going to do past some arguments into it, and those arguments are gonna be our variables Now, you could put these as for the most part, whatever you want. But of course you want to give him in order, and you may as well give them their proper name. That way, it makes sense. In this case, all we need to pass in right now is our lives from our player. So when we received those lives, we're basing on a check. If our lives are less than or equal to zero, we're gonna go ahead and rob our dialogue here and do a pop up. Uh, do you want to pop? Know what you dot show? We'll just go ahead and show it so our pop up dialogue does show, and then we're actually going to pause our tree. So we're gonna do you get tree pause equal. True. Now with your go ahead and select your pop up dialogue and are a century and over in the inspector go all the way down to where it's his paws. Open that up and make sure you change that to process. Otherwise, your game over box here will stop running. And then you're pretty much re stuck in a non responsive game, and we don't want that. Go ahead and save your scene like this is college B y cool. So now we have our game over screen to pop up when we have less than or equal to zero lives . Now we're gonna need a few things. Still was still going to need our play again. But to work in our equipment to work let's go ahead and passable signals in but pressure potash into our script. Okay, so play again happens, man, we're simply first off, we're going to on possible Cherie. So get tree dot Paused equals false. And then we're going to reload the tree. So get tree, not reload current scene just like that. And if we were to hit the quit button, we're simply just go get tree. God. So now this works. The problem with it is we're actually not Paschen any argument? So it doesn't know what lives are yet. For now, we can hit IHS, but right up here at the top in the top, right to just test this one scene. And we have nothing because our pop up isn't going to show. So if we just go into ready, we actually do the pop up dialogue here just to show it to test it and I to see if we hit again. Nothing's gonna happen cause it's reloading this same scene over and over. If we quit, the whole thing will stop. So you can do that. We just want to test that real quick to make sure that your script is running the way it should. And now we have to We have to update our g y from our player. We need actually pass in this argument from our player. And to do that, we simply just go to our layer script here. We're going to create a function all the way down here. Cold update G. Why? We're going to give it the same name, just, ah, prevent any confusion. And now, in order to pass in our arguments, we're going to just do get free and then we're going to called the group This why we needed to give it a group in that group. This is gonna take our tweets. Our first group are our first argument going to be the group, and then we could dio comma. The next argument is going to be the function we want to call in this case. Update, update do you? I Mama next argument are going to be things that we want to pass in. Select our variables. In our case, we'll go ahead and pass in lives because that's the only thing we need to track at the moment. And now, when our lives is zero, instead of printing, you have died were go ahead and call the update. She y function. Now we go ahead and play. Once we had zero. You should come with the update function and the update function should notice we have zero lives and then give us our pop up over. We do need to actually add it to our scene. It's over here. Level one. Let's instance in our July and there we go. All right, let's go ahead and hit play and take a look. La de da We go one to Wow, Look, we're winning. I I want to her. I meant to get hit by him. It would just use the top guy here. No. One to three. You see, everything is paused, our game over screen. It's popped out. We can hit play again and everything restarts from the beginning. If we hit three times here we can now hit quit and sender game. So there you go. We have gone ahead in I've shown you one way to create a game over screen. No, of course, are a few other different methods that you can go belt Teoh, Create one if you want to make yours mawr unique and special looking instead of using basic buttons. And that here we're free to go ahead and experiment and I'm go above and beyond. Your code is there. You just go ahead and decide how you want it to look. And with that, I'll see you guys the next one.
20. Win Condition: All right, everyone in this video, we're gonna go ahead and create Ah, a winning conditions for game. So go ahead and create a new too d seen and give that a scraped an area to D and a collision shape. Give our root note a script and our area to do you want to connect the body entered signal to it and for the texture honor Sprite. I'm just using the green key. And if you don't know where that is, that's just under textures and items. You can use whatever item you would like. I'm going to use the green key for this now, in our script, we are going to do the very something respect this year. Here we go. On our area entered were simply going to do well. We're going to do two things. First, we're going to check, Yeah, player in body, not name. And if so, then we're just going to call a function cut body. What should we change it or set it to, um, call a win condition and then we will queue free. So before we jump too far ahead, let's go ahead and jump into our player going to create a variable called has one that's gonna be true false. And we'll create our function called when condition I was gonna double check. Make sure. Yeah, wing condition. Okay. And when that gets called or simply is going to change has one too true. That's the only thing we're going to do there at the moment. Okay, Next, we're going to need and exit for this. I'm just using where you need to grab the exact same thing. So you have to root note a scrape area and a collision. And our area is going to be same thing here. Body entered. And for this great, I'm just using a locked door which can be found under textures. And I believe other is yes, under other. So once you have that again, slap he script on that and connect your signal. Oh, boy. Let's see for this we're gonna have to go ahead and create a function. Who needs the ready function here, and we're going to add two groups and I'm going to call this exit for my group. Um, for my group. Ah, let's create a variable here called Winner. That's going to be a bull set to false my depot. We're gonna need a another function because we need to able to change winner eso function. Um see Update winner Simple. And we're actually gonna use our as one variable here, and we're just gonna set Winner is equal to has one that way. Whenever has one is updates to true winner will become true now. To do that, we actually will pass this argument in. So for that, we have to go back to our layer and under win condition, we'll go ahead and also call in update winner function, which we start to create that so great that road quit day when there and this is just going to civil b a get tree col dot com group the group being exit be function we want to call is up the winner and we're going to pass in the argument, um, are variable has one. So take this step by step so far when we pick up our key So we're gonna pick up our key was gonna check if player is what touched our key and if so, is going to run the wind condition on our player which changes has one variable to true and calls Update, winner Witchel update Our our exit door call the update Winner Over there in Pass on has one which should be true and was set Winner Equal toe has one so that between winter to true and then the key will delete it So and so far we just have to do one last thing here. And that is on our area to D body entered. We're gonna check if layer in body got name and winner. Yes, equal to true. This is where we're gonna pull our when So for myself, I'm just going to go to my G. Why here? And just add a pop up called Winner. And just add a rich text label that just says you win now, even go ahead and make this as fancy as you want. And I would encourage you to do so. Um but this is basically gets the job done. And at the very least, it'll work as a place older for me to come back and update in the future. But for now we have that and in our view, I script. We can go ahead and just create a function cold winner and in this we're going to haws our script cause equals true. We're gonna pause everything here and then we're going to also show our winner just like so . Now remember where your winner pop up. You want to make sure an inspector pause is set to process and now all we have to do and our exit If a player is in the body, name and winner is equal to true. Would you just now call the function? Get tree? Yeah, call group our group being Gee, why? And the function we want to call is winner. And I was going to take a look. So now when we pick up this key, it should now change has one too true. And then up the I'll call the update on our on our gate, which will change winner see True. Just like has one assuming I don't die twice in a row. Oh boy, there we go. And now when I touched that door, since I am the player and winner has been set to true, it should call the winner command on R T y. There we go, he went. And to show you that if you don't have the key than winner should not be sent. The truth. It's still we both, and thus nothing happens. Nothing happens when we entered. No matter how many times we try now as the player, I have to come right back here, pick up that key and then make my way back over to the door. And now I went. Hopefully that wasn't too confusing for you guys. If so, you can go back. We watch this again, maybe watch a little slower if you need to, or posit here and there just to keep yourself up. If you have any questions, go ahead and ask them and I'll see you guys in the next video.
21. GUI: All right, everyone in this video, we're going to go ahead and create the actual you I for our game. So we're just gonna go ahead and open up our g u I seen and go from here. I've gone ahead, and I've just hidden our winner, Papa and our game over Pop up that there we go. And with our canvas later, we're going to go ahead and we're gonna grab an outline to start with of our items. Um, in my and my game here, remember, I used the jewel. So I'm going to use the Jewell outline, and I'm actually going to just drag. And I've got three of them. I believe in my level. 123 Yes. All right. I'm just gonna take these and I'm gonna go ahead and place them. Grab these, bring them up, and I want to get them as level as possible. Of course. And this is getting a little Come on. Ah, there we go. OK, so I'm gonna go with this one, so I'm gonna go to transform, take a look, even that out 34 23. And now we want to go ahead and get the why 23 apply to all of them that there are even now for our X. We're at 34. I want to make this. What do you want to go by? Um, Let's see. 34. Okay. I don't know. About 100 now. Somewhere between sixties, almost not touching. Still 74. Ah, you want to go with? Yes, post, since we only have 3 74th finding and 64 is not touching, but almost so. We could go with that as well. And with that, that would just be a plus 30 each time. So that would make our last one here 94. Nor to make those three even. I am. I think that looks fine. But if you want to put a little space in between each one, you definitely couldn't. That's up to you. But for now, we've got those. Ah, if you want to go ahead and make even more in here, if you plan to have more structure, other levels or if you have more than three in your level, perfectly fine. But what I'm gonna do for now is I'm going to group these out to do them. Is going on my campus late, and I'm gonna add a regular node and just call this jewel outlines, and I'm just gonna drag all three of them into their. And now, when I move, this actually moved all of them. Or at least because it's just a blank notes. I'm sorry, I won't move on, but we'll actually have them all together in one location so they don't get all mixed around in our trees or anything. Next for Ushio need a our tools itself. I was gonna go ahead and drag mine on, and we know our location so we can just go 34 23 now fit during another one on. And we know this is 64 23. Oh, I'm sorry. I did not mean to parent those past the one and Rio 64 23 And one more boom. That looks close. What do we got? Very close to 94. 23. And again, I'm just gonna go ahead and group all these ones up collected fuels, and I'm gonna bring those run on it. There we go. Ah, so it's er these numbers? Yes, and cool so we can start looking at this. We look, are you I We're not gonna see anything there yet. Save there. And there we go. So we're gonna be looking at that. Would go and hop in and take a look at that. See if we like the position. A position? Definitely. It's fine for this game. Um, personally, I think I'd want to make it just a little bit larger if I was making it myself. What? This? This works. This would definitely where far what we're doing here. Cool. Already. So now that we've got that, we've got a position that we're OK with, We can go ahead and go into our script and in our ready function that we want to set, um, that way, or we will hide our jewels by default. There we go. That'll do know we'll have to take up a much script power. What? We can create a function now. Do we want to allow our layer to control our jewel count here could do this to a global scrip, which would probably be the easiest to go through. Um, but do we want to go about that? So if we don't And when we picked this up after you add, we're just gonna have to call another function, which is going to get even more. Yeah, let's go with a global that we keep script size down because then the less, um, code that your script comes to execute go through. Of course. Theoretically, should be better performance. In the end, though, a game like this shouldn't really make any difference. And what drug it and global actually is not gonna cause any issues from where we're going from here that's going create another variable ever go. We'll call this jewel count. It's gonna be an interfere, and it's gonna start at zero. Okay, so let's go ahead and do it this way. No. Whenever a jewel is picked up, we're going to go Go ahead and dio maybe. Yeah, Jewell count equals maybe. Ah, Jewell count plus one. All right, save that. And that's in our Jewell script. Whenever we pick it up and now back over to our G y script, we're gonna make another function here. Um, go ahead and just do it here. SOS to function. George collected, would you? Yeah. Yeah, Global, uh, jewel count equals zero than well, everything is hidden, so do nothing. So we don't really need to do that. Eso Let's start with one. When we have one, we'll go ahead. And our first grain Jewell here, we're setting it. Wanna check? Double equals there. We're gonna get our first green jewel, and we're going to dot show. So when we pick out one Jewell we'll pick up a Jewell. It'll add one toe are counter When the counters one, it'll show a virtual. It was gonna go right up to our, uh what talking? Ah, being ready. So, actually, I need a process function here where we can go ahead and put our Jewell collected. Now, if we went ahead and did this with a player controlled it, which will go ahead and take a look at that as well on then we wouldn't need a day process function here. But for now, we can go ahead and take a look at this when we pick up one boom and now it's shown up here . I can show you that again. It's empty. We pick one up boom. Now it doesn't matter which you'll we pick up. Still going to go ahead and count you know this one poem? That's one. And, of course, we don't have anything set up for the other. So it's going to Curry does nothing but to continue this, we would just have to do it. Maybe you'll count equal to And then we would just get the next one. And so and you get the idea. This will be three and three Now, you see, as we picked him up room Boom. Um, we have a little bug in there. Okay? So inner Jewell, what if instead of putting it there right after animation finishes, is that gonna cause any issues? Doesn't cause any issues, but it does cause a small delay. Okay? No. How can we fix that? We could probably fix that with in here. Let's see. Probably fix that with just putting a little timer. And here for us to wait. So yield, get tree. Great timer. Ah, C 0.2. And of course, time out. Let's give that a shot. There we go. Now it looks instant, and we've gotten rid of the little bug that we had where we could collect multiple off a single Jim. So that's one way that we can go ahead and set. Our collectible, I said, are collectible, and we can go through and Specter R two d screen here, and we could basically set the same thing up. But for key, we can get our key outline. You can place that wherever you would like. Go ahead. And, um, not sure why I want this at, um transform que this it 23 that was 94 cents will be 1 24 followed by 1 54 And that will do for now. Then let's go ahead and grab our key trust in there. 1 54 23. We're gonna hide the actual key and keep our outline And let's see for our layer, because we are We already have that set in there. What? Our player right here from God has one is set the phones so we can go ahead and pass that in his well. Ah, so wordy. Updating Doing update. Winner here in our wing condition about that. It's on the wing condition. Which Concept eight winner has won, Right? That's for that cool update. GeoEye. So we're gonna doing here is we're gonna go ahead and add on to the end here has two comma space has once will also pass that argument in. And then whenever we let's see on our key, we're gonna call wind condition. Okay, So inside of our one condition here, which is gonna go ahead and to update G y. So we just add that in there, and that should update just fine. And now honor GeoEye here and our update function, we dio comma space as one because that's our 2nd 1 that would you if has one is equal to true. Then we're gonna show our key key Green Show, and that should work. We got our Jim one to three, and this are key. And I would just walk out of our level now if you wanted to do your gems like this are using the update. Gee, why then all you would have to do there, um, to do it that way is, let's see, to do it that way, we could just dio create a variable on fuels were called Jules. So you don't get confused. Entered your I will say it starts at zero. And then we would simply just to create a function here function Jewell collected I just called my function inside of itself. It's just your fuels equals fuels plus one and then update. Do you I and or 1/3 argument will just do. Jules. Yes. Since we added jewels there, we're gonna have to actually at that in our update here Cools and then in our tool script. Instead of doing these two lines here, all we would need to dio is you body ya. Ah, What did we just go Jewell collected yet? Jewel collected. Go ahead and copy that. Make sure we get it all, and we'll just go like that. And this should have the exact same result when we pick up a gym. We did not set it in our g y. So we get that and then space in there. And this is where we would dio if Jules equal one. And I'll just go and grab this show that it fuels equal three whom that should be three to . And then if fuels equal three and I should be the exact same result. Okay. What did I misspell bodied? Actual collected? We just said update. Now up the in July. Here we go. Little type on my part, and there you go. So if you want to do your jewels the same way as we did our key, that's how you would go about doing that. Okay. Oh, I seem to have a collision. Well, im going toe. I didn't actually tweak that in our collision box over in our towns that but you can see that's how it works. And that's two ways to go about doing that. Now, obviously, if we're doing it this way, there are update g y. Then we do not need this section. And we do not need our Jewell collected function at all. So those are two ways to accomplish the same thing in our GeoEye. Completely up to you. Now. You want to go about doing that? Now let's go ahead at in a lives counter on screen. Okay, so let's go in. We can just use a rich text label will make this lives go like that and would do X zero. Do you wanna go like that? Are zero ax? Uh huh. Certain Let's go with lives. Colon zero would just go with that for now. And we can set that. Where can we said you just set the underneath here. See? What a Well, Okay, um, I guess that's gonna be it from now. Let's take a look. See what that is. Yeah, that's right There. That's that's perfectly fine. Curious What? This is what is in there? Don't know. Scroll active. Here we go. No. If you want to get into adding custom fonts or if you have your own graphics that you want to use, you can definitely go ahead and do that and pull that in. It's perfectly fine. I'm gonna change this to lives. And as we could see, it works. It's their awesome. Now let's give it some function. So in our G y, let's go ahead. And we can add on first off to our beginning part here. If lives less than or equal zero. Then we can just dio dollar lives. Text equals lives, Colin Space. And then we do plus lives. And I'll just go ahead and copy that. And we do. It lives equal. 21 We'll do that again. Yeah. Lives cool to Yeah, You know, we don't have to do that instead of copying that the entire thing the entire time. I actually take this section and we just set that before or after. Well, said it after. Right down here. Now, Indentation is very important to make sure when he tabbed over once, not twice pace that in. And now that should update our lives every time. And, of course, once we hit zero, everything will pause. And that'll be that. So we're gonna convert that to a string. That's what it's gonna yellow reports. That has to be a string to go inside of that text box. Boom. Okay, so that's not updating. Why? Because our hurt function should be up dinner. You I That's Onley when we lose one health. Now we just have to go ahead and at in here. Ah, whenever we get her. Okay, G y. Here we go. So we just weren't updating it. And you know what? Once we start the game I'm hearing are ready function. Francisco hadn't updated update RG Why that way, no matter what, our lives would be set. There we go. And when we get hurt now, 32 one, zero game over scenario. Now we have a little lives counter in our game, so the player knows what they have left who? We've got a collection here for our collectibles to show up on screen. And we've gotten rid of a little bug that we had with it if you wanted to do it the other way, and we can now collect our key that we also need four to win and whoa, I almost lost on that one, and we can walk in and everything's still wins. So there you go. There's how you can start creating a U Y for your game. We have our lives counter. We have a collectible counter that updates as well as displays and fills in our outline as we collect things. And we have our key that we need for winning, which gets filled in as soon as we pick it up. So we know that weaken exit out of the door. All right, so that will do it for this video. I hope you have fun creating your own. You I and I'm here to see what kind of things you guys come up with. Their you're gonna go with something. I'm simple and minimalistic like this, or you gonna go above and beyond create something completely unique, different in bringing your own graphics. But that will do it for now. I'll see you guys in the next one
22. Tileset Collision Fix: all right. It one and this one. I just want to quickly show you the how to fix that issue I was having at the time up where I went, right, But I couldn't go left, okay? I didn't show you this real quick. Boom, Boom. We went right then we couldn't go. What? There we go, as you can see there. And the reason for that is we have a collision issue in our tile map, So go ahead. And in our seen here, for me, it was this Glock. So with a blank square go and just left click and you'll see the block it selected over here in our tile map, which is tiled blue 05 Now, if you don't have a blank square because it's a control Z or controls that and left, click the block and that'll select it there for you. So go ahead and open up your tile set scene. And I know it's tile blue five because we found that I'm gonna go to my collision and you see, if we zoom in it, money is just a little bit above our block here. Just going to grab that and pull it down. Line that up. Better go ahead and save our scene. And I was just gonna do it. Did before we're seen convert to hyo said. Now, where did we put this sort of thing? Textures, tiles? Was it in here? No, There's tile set. And just go ahead and overwrite your tile Set name when? And we're not gonna merge with existing. We want to override it, Okay? And okay. And that should fix that collision issue there, and we should be good. Boom. And there you go. So I just had a small lip in my collision. So if you have an issue like that yourself, that's most likely what your issue is. There is something with your collision. Either one of the blocks decided, being a little too low or that block being a little too high. All right, so there you go. That's how we go ahead and add that in, or rather, fix that small collision issue. And I see guys the next one
23. Pause Screen: All right. Welcome back, everyone. In this video, we're gonna go over how to create a pause screen. So first up, go up into your project settings, input, map and rocks. You need a pause button to go ahead and add the pas action and assign it to whatever. But you would like, I'm using the escape key. And for this I went ahead and just created a how a pop up here. Another problem. Dialogue with some text inside of it that just says paused. We did the exact same thing when we're doing the our winner and came over pop ups, so you should know how to do that. It's very simple to quick nodes, and then we can head right on into our script. Okay? We're gonna go ahead and create a not great, but use a function that's built in called input event, and we're going to check if event God is action press and are actually going to be pause. Ben, we're way. We'll create a variable here called state people to not yet tree pause and then simply put with, say, get tree. Yeah, pause equals two apostate. And then to keep everything in line will also do are visible. They are not visible dollars and we want the ha screen visible also equal to our apostate. Okay, let's go ahead and jump in and we hit our pause button and there we go. Everything pauses. We have our little box that pops up telling us the games with ties. I really press it again. We have Teoh canvas layer. Since that is holding our script for possible we need change that to process from inherit. Here we go, there we go. We can pause an unpolished our game at any time. Of course, we can't run around and it says we a NPAs boom. We could paws in the air and everything perfectly fine. No, we did actually do a double pick up on her Jewell there. So I guess what? This will go ahead and actually keep our time out there. Keep our small timer to avoid that. Just as a safety precaution whom never go with killed all the enemies. We've got our jewels. We need one more. We've got our key and we went in. There we go. So there you go. And easy and quick way, of course. Go ahead him. Create a pause button for a game. Now, if you want to go ahead and add a maybe a color rectangle note and just make a black and change the opacity on it so you can darken the screen. You could do that. That's cool. Just make sure if you're going to do that, that in our G I hear that you also add, you come in and you get your your color wrecked, whatever you call it, that visible equal to your positive, just like we did it here. But with that done, that's how we do a quick a quick, a quick, um, posturing for your game. All right, see you guys in the next one.
24. Addung Audio: All right. Welcome, everyone in this video, um, we're gonna go ahead and add in some audio now. Now, for our selection, I've went ahead and grabbed a coin collection sound here from this website from this crater as well as a jump sound effect. Now, free sound is Ah, great police refining different sound effects for your game or other media. And usually, if they're just gonna fall under a creative Commons where people want, of course recognition, they want credit. Well, let's go ahead and jump in and let's go to our players scene and we're gonna have an audio stream player. Two d. We don't need three d. We don't even really to be willing to steal audio stream player and we'll call this jump sound. And what do you want to stream jump 03 wave? Just drag it on in and you can go ahead and adjust the volume and pitch a few things there . If you would like and just tick on, you wanna sample it? I think I want to lower mind a bit. Let's try negative 30. I think that will be fine, but we'll see after we get some music and later. Let's go ahead and jump into our player scrip. And under our jump function, we're now going to go ahead and at in our jump sound top play. Let's go ahead and test that when we get in, whenever we jump, we should hear that sound. There you go. All right. Looking good. Sounding good. So it's going over to our Jewell script and open up our jewel scene. That makes sense for us to put our audio over there. Let's go ahead at in an audio stream player, and we'll call this war collected and we go ahead and dragging our collective coin again. You can listen to that beacon. Changed the volume on it. Pitch whatever you want him to deal for your game. Negative. 20. How about that? That sounds good. Maybe even you're 15. That would be good. All right, um, body jewel collected. And we're also gonna go ahead and play. You'll collected Play. Right. Let's take a look. It seems we are running into a little bug there, So go ahead, extend our timer a little bit already. It looks like not having any We're have this. Well, that is interesting. That that is coming there curious. All right, we'll tackle that, uh, tackle that in another videos. Interesting how that's still happening much for now. We've got our jewel collection sound. We've got our jumping sound. Let's take a look at music. Let's go into our lover one. Go ahead at in a Stream player. We'll call this Be GM, and we go ahead and add in this quirky action music. Now you can feel free to go ahead again on, like, a free sound or anywhere else, or even creature on if you want for your music. And I'm gonna change this to negative 40. I feel like it's loud. Let's take a look. OK, I was right. Negative 40. Sounds pretty good. Maybe even negative 50 for this. We're gonna go ahead and make sure we have auto play set on now. Whenever the level loads up, the musical start right away. Way cool. We got all our sounds. Um, for the key. We go ahead and add that same sound in for a collection that that'll be fine too. He collected and would just bring in our collect coins. Sound lower this again and maybe we adjust our pitch Mm. There you go. There's something a little bit different with a small tweet analysis of our key script. First, we're gonna come in and we're just gonna play simple. Is that okay? That seemed like it was the audio was too quiet. Let's go ahead and bump that back up and take a look at our key again. Okay. Seems like her key is actually not playing our sound because it is doing this too soon. Okay, we will wait well ahead and connect a signal for when our sound is finished. And then that is where we will do our Q three. What is going on? It's actually finishing too soon. There we go. And I suppose an alternate way to do that is after we place to use our yield again and just wait a little bit and then Q free. But that's fine. This will work. And again, let's go ahead and edit this crackdown minus 15. Take a look, see if that's too quiet or die and fail. Okay, I am playing really bad way on. If you want, you can go ahead and at an animation player and shrink the key just like we did with the jammer. That's something that you want to dio. All right, everyone. So we're gonna go ahead and use this and jump for here for enemy when we bounce off of them . So let's go ahead and open up our scene with Walker in. Here we go. Let's add an audio, um, player bounce. And on death, um, poop player her body enemy jump. All right, so in here, we'll go ahead and clear. Sound whereabouts that play. Go ahead. We sign it. We did not the safe jump for Pull it in there. Give it Are negative. One e Let's go and take a look here we owe. Could even do with probably lowing that lowering that volume a little more But there we go . It all happens. Let's see. Can we add any more audio that we need? All right, let's go ahead and open up. Um, where we, uh, our exit scene. And let's go ahead and at an audio clear to that we can unlock you will play this door unlocked mile in that see about making an adjustment. That and then in our scripts, when the player enters, we have the newest Let's play that sound all right. Let's take a look. I bumped my head. Oh, I got it on the way down, Ugo and it does that wage a quick. So let's go ahead and we'll move this up. And we could either wait or just wait for the sound of finish. And then we'll call this down here and then we just delete it out of there. And now we can go through and it should work just fine. I bounced into it and it seems like we have a Super Mall issue of Grab twice. Here we go. So there's but all the sound that we really need for this game. We got our jumping weaken. Gotta sound when you jump on the enemy's. We've got background music. We've got collection sounds. We've created a new collection sound by modifying an existing audio file that we had. We have a sound only unlocked the door on the That's what we really need right now. So with that, take care. I hope you've had fun during this course
25. Fixing Some Bugs: All right, everyone in this video, we're going to go ahead and create or not create. But Glenn fix some bugs that we have. So currently, we go ahead and jump in, you know, so we can pick the gem up twice. Still, even with the way that we haven't set up, if you're quick enough, try that again. You go. In fact, I picked up three times, so we're gonna go ahead and fix that a very simple way. Instead of waiting for animation to finish, we're gonna We're just gonna queue free after we wait. We're gonna change our wait time to zero point to You could try 0.1, but I feel like I would be too quick and then we just We can just comment that out or delete it. And if you want, you go into your signals, right? Click and hit. Disconnect. And now when we jump in, you see, we're still would've picked up 1.2 Such change. That one. It's a very quick sound anyway. And as you see, no matter how much I try, I'm not running into that issue anymore. So we should easily be able to do that with our key as well. So it's something to our key. We got key collected, and we'll just go ahead and copy this over from boom comment that out. And I should still play just fine. There we go. Okay. Which means we can now just delete that out. And what was that for key collections? Sound finished? That's anarchy scene. And we can just go ahead and disconnect that signal since we don't need it for this. And now we fixed too of our scripts. I'm gonna had just delete that one in school. Now with our G Y. This is gonna be dependent upon your game and the way you have your set up. So I'm just gonna go into my inspector and you'll siege on my player seen here The camera to D. I have a limit of mine here, going down 1000 pixels. So I'm going to use 1000 as my limit. Um, if you have a different limit or if you just have solid ground on the ground on the bottom , that's perfectly fine. You might not have to worry about this, but the issue we're gonna fix here, we see if we miss a jump and that's it. We just sit on the screen forever until you restart. Now, you could either go into your project settings and create a restart key. And whenever you press that button, it restarts. But what I'm gonna do is I'm just gonna go into my G Why script and let's see. Do we have it inside her player? No. Definitely. And RG Why? Where Just quit winner play again? Ah, right here. This is where we're just drug in a pause. So I'm gonna go ahead and just copy this section and creating new function called Game Over . And I'm just gonna go ahead and paste that in there just like so in our lives less than or equal to zero. We do just do game over. Okay, now, over on our player, we can just look at on you have to move or new. Um, okay, we can just go ahead, and I guess we can put it down here in our move section and we just do it position dot Why ? Of our players position is less than or equal to, and we'll create a variable here called World Limit. I would just go up. Yeah. World limit interred your for me that 1000. So if our position is less than or equal actually not less than we want greater than the real greater than or equal to our world limit then all we're going to do um actually couldn't move that into our gravity, But we're just going to get treat out called Group. Gee, why and then the function we want to call, which is game over, just like so. And I think that's what I'm going to dio. I'm gonna go ahead and just grab this and move it down into my gravity section. All right? So let's go ahead and take a look. Oh, equals, Here we go. Perfect. And now, if I go below my cameras limit, we should trigger the you game over there we go again and that will restart us or we want to quit. That's still gonna end us just fine. So in your world limit, you can create a variable called world limit. Set that to whatever your cameras lowest point is and then I sent mine in gravity. But you can set it wherever you would like and just dio if position dot Why is greater than or equal to your world limit? Then we're going to get Tree called Group You I because I want the group name and the function we want that group to do, which is our game over function and in our g y, our game over function is gonna open up our game over crackup, and it's gonna pause the game. All right, so there we go. We've got ahead and we fixed a few of our bugs, and we should be Our game should be all set and ready to go now.
26. Adding A Background: All right. Welcome, everyone in this video, we're gonna go ahead and just at a parallax background into this, and we're gonna make our backgrounds this costly Repeat. So if you're level keeps going to the right a lot more than mine does, then it will just keep repeating over and over, and we won't have any blank areas. So to do this, let's just go to our level seen and we're gonna go ahead and add a parallax background, and inside of that, we're gonna add a parallax layer. And inside of that, a scribe Enough of this crate inside of your Texas folder. You're going to see Background Folder. We're just gonna grab that image and apply that we're texture. And then I'm just gonna go ahead and line mind here, So And to make sure mine, I feel some of the bottom here when we get to the our bottom platforms. I was gonna stretch mine down a little bit like that. Now let's go into our parallax layer and under motion for mirroring. Since this image is 19 20 by 10. 80 we're gonna mirror it on our X axis at 1920 and now you'll see it appear twice and only twice. You won't see it Any war resume out, but it will continuously repeat past that. If you're level this part now we can jump on in. Oh, and I apparently died and I bumped my head. But you can see we've got our back around here way. Keep going Over Right, you see, are things just continues on how far over we go? And if we were to look at this, you can see that there is where Oshima's which the better image. You have to repeat it better. So you are gonna have with it. So that's all we really need to do in order to create a back on in here or our platformer. I will continue going on and on for as long as you need it to work as long as your level is Now, if you need to mirror on the wise well, you could. However, you needs a little bit more of a specific image because, you see, if we were to mirror this one, it would look a little We're having the sky back in the air like that. So in this case, we're only gonna mirror the X. That's really all we need to do here, Teoh at our backgrounded two. Simple is that quick and easy, and that will do it for this video.
27. Main Menu and Fullscreen: All right, everyone, let's go ahead and create our main menu for our game. So clearly here, we're going to need a new scene. Um, let's make a user interface. We're gonna go ahead and add and let's go with you are textured rectangle. Or do Now let's let's just go with a scrape. We could go with the texture. Rectangle wouldn't make too much of a difference. But we're gonna go scrape here and in our textures menu your find a main menu. PNG. Go ahead. Just bring that in and line that up. See? All right. I think we've got it there. You wanna be a little safety? Those? We get a little bigger, Then you need now. Next. Let's go ahead and add in a see a texture button and pull in, um, architectures for normal. Go ahead and pull in our start button. And then for hover pullin our start button now. So would you spring that right on in? Um, yeah, let's go and put it there. Now. For the size of this, we would have to go to this scale since or using a texture instead. It's great. That's fine. Will be under wrecked here. Scale. Let's go, Teoh. Is that good? Yeah, let's go ahead and just send our skeleton SharePoint pie. Okay. Now, before we dump it, before we jump into a script, go ahead and add and options button as well. And we're gonna rename our texture button too. Start button, Mary. Name my stripe to background. An options button is fine the way it is, And I was gonna extend it out. There's something like that. Okay, so now we're ready to start jumping into our script. Let's go ahead and add a script onto our control note here. I'm gonna call it made menu. We should add it into our script folder. And what's through? No comments. Reorganise the ready function. Start off. Let's go ahead and export a variable year. And this is basically just gonna make it available in the inspector. We're gonna export no path. Variable drop down and then unready variable drop down equals. Yeah. Note. Drop down. Yeah, heart. Go ahead and save that. That is our main menu Seen. So say that into our scenes. And now you'll notice in the inspector. And there here we go on our main menu underscored variables we have dropped down path. Go ahead and click the assigned button and select our options button. And we could go right back into our script. Okay, so we're gonna need two functions here. Our main one is going to be at item. Now. What we're doing to this is we're Basie gonna add in the options for a slick, and we're going to use this for effecting. So the player conflict windowed mode and full screen really, of course are Start button is gonna start. The game is going to change your seat. So add item and what we're gonna add in here, it's gonna drop down. Done head. Hi, Tom. And inside of here is gonna be the name of the item. So we're gonna go with windowed and we're gonna do it again. Drop down. God! Ad item Now we're run this scene right now. That's what we got. But we should we have to add item under are ready and item. Perrigo, along with this one. And you see, we have window and full screen as our options. So we have our options. What? They currently don't do anything now in order to get this to do anything. We actually have to connect a signal. And you could click on your options when you go to signal and shoes items selected here and connect that. But I'm going to go ahead and add mine. Connect my signal manually. It's up to you. If you want to do it manually or selected from there, we're gonna get the same result So on. Ready? Would you drop down? Uh, connect. And we're gonna dio item selected, which was the name of the signal that we saw there. So and the name of our function to keep it easy, we just do on item selected and now our signal is connected. But we needed to actually do something. So we're gonna create our function on item selected. Now, remember, if we take a look back over a year, this requires an i d. So we need Teoh, go ahead and pass in an I d. For And we're basically gonna check if the i d is zero, which will be our first option windowed Then Os window bull scream equals bones. And then if I d is equal to one which we are second option that we called full screen O s got window underscore. Full screen equals True. Now, if we go ahead and jump in this scene, we change this boom. We're going to full screen. We changed back. Go back in the window now. You saw we had all this great space weaken easily. Fix that. Just we're going up to our project settings. We're going to come on down to words window under disk way, Scroll down to the stretch section remote. Set that to two D aspect ratio. You set that, too. Now, when you run that and we got a full screen there we go. And back to window and you notice with our button away we haven't set up. When we bring our mouths over, our colors change. So that's great. We have our options menu here working. Well, now we need our start. But her work start button. We could connect it through script here again by coming in here. And we could go start button connect. And I believe it is called breath when we just go ahead and double check that. Yes. Press fell. And would you on start button, right? Not just copy that, then right on down here function on Starbuck Press. We're just going to simply get tree and change your scene. We're gonna change it to level one area. Let's go ahead and jump in. Take a look at that. We hit Start, you go. We're in our game. I'm not sure why that guy was freaking out. He couldn't go the side here, so that's a little odd. But you see how the game works just fine and we can go. But we actually to reset our main see now from our level to actually go into our main menu . So it's got a project project settings and let's see, where is our option here year ago. Application Run. We have main scene. Go and click the folder and select your main menu. Now, when we hit play, we get our boots screen, our main menu. We can select our options to full screen. You can start our game, Ugo. There you go. They have. There's how we create a main menu for our game with our and how to do our full screen and Windows options.
28. Touch Buttons: I welcome everyone you'll see attached to this lecture is going to be another set of assets . This is just gonna be some touch buttons that you can use for your game. And we're gonna go ahead and implement those in case you want to put this onto a touchscreen device being a tablet phone or any other device that's out there that has a touchscreen. So this we're gonna open up our G Y screen, and this is where we're gonna put our but we're seeing Decide where you want to put your buttons. But for now it was discovered. Canvas layer and let's add and we're gonna add We need at least three touch buttons for this. Just pull all of the zone. There we go. I'm gonna call the 1st 1 left our 2nd 1 right, and our last one will be our jump on. So let's start with the left button. We're going to go ahead and just drag our left button here. I'm not sure which button here is What, but we'll find out smi dragging it in. Let's see. Ariel 32 is our left button, and it's gonna pull that down a C area 30. We're not 32. Sorry. 22 23 years, hopefully are right. But then perfect. And they would need a jumper. Let's see what 24 is 24 up. You could use that. If you want to use that for jump, you definitely could completely up to you 25 then is probably down button. So if you have, If you would have had an added a ducking animation to your game, you can go ahead and use the down button for a duck. And 34 here is in a button, which I'm going to use for my job. Okay, so let's take a look at these. Let's make sure all of our things are set equally. It's gonna be 47 on R Y. We're on our X. And then what's that? That even for 77 are right button 1 50 What are Y for? 77 to keep it perfectly equal and are a button or why will also be for 77 and her ex was sent as an equal a 20. Okay, let's see. Should we set that 20 of those? See, this is 47 away from the this is. Yeah. Okay. Well, let's go with that. And just leave it like that. Now, for all three of these buttons were gonna go into our inspector. We're going to go to the action, everyone and type in the action that we want so far left. But we want it to be our action called Left for right. Wanted to be our action cold, right? And for jump wanted to do the action that we called John. Now, Capitalization does count here as well, just like in our script for make sure you get that correct. And if our visibility mode we consent that to touch screen only and then this will only show up if we have a touchscreen device. Otherwise, this will automatically be on which is perfect, cause that's exactly what we want. You don't want to play a game on your computer, and then you have these touch buttons all over the place. Now, you could go ahead and test that, but they may not show up for you because this detecting your computer is not having a touch screen to solve this and actually test our bunch would go up here into our projects. Project settings and then under our general tab, come on down here to and put device and pointing and your see emulate touch for a mouse. Go ahead and turn that on. Now, when we start up our game, you see, we have our touch buttons here and right when we was right, left with just left and the other are other button that whatever you chose, they're gonna do our jump. And she's still place our sound effect and everything because the engines, assuming we're pressing that button, which has that label of jump or moving, just like if we were to use our keyboard to move these Now if you have, If you had a touchscreen, why she could definitely move them left, right and shop. You could complete your level. Now, of course, we had something else going Then that would, if you had more to your leveled and he had more buttons. We do the same thing. Go ahead and slap mint here, Um, to you, I seem now the reason would put them in Archie Wise, The same reason we have them up here have they are icons up here is because we have it inside of a canvas layer and inside of there, and it's gonna follow our screen the whole time. Otherwise, our buttons would stay on the level and our players Don't you press it when we got there, that's what we want. Wanted to be on the screen at all times. So just to show you here I come into my project settings and I turn this off so it doesn't take my mouth, says I touch input and I hit play. You see, my buttons are now gone, which means, and I cant I cant click them, some not just invisible that is completely gone. And I could just play the game like normal, and we get to the same result here. Now. You don't have to worry about your buttons here because they will still work with a touch device by default. So if you have this on mobile, you can still just go ahead and press. Just tap on those buttons and they'll work just fine. So that's it. That's how we go ahead and add touch buttons on to our game so you can go ahead and put this on to your own mobile devices.
29. Export Your Game: All right, everyone. Now that we have our game, it is complete. We can go ahead and export it is that we can actually just play. We can run our execute Herbal played on our computer. If you plan to move this to a mobile market or even just side loaded onto your own device, you can go ahead and do it that way. So now that we're done, we just head on over to project and we gotto export we had add in our presets. And if you wanted to do it for Android, he could and just run through all your settings here that you want to change. Um, this is one thing that you're gonna have to take a look at is you're gonna have to look at how to create and get ahold way key store. Now that is completely separate onto this. And that is some extra work you're gonna have to you. I'm looking to outside of this course. IOS is the same way you're gonna have to get as you see an apple store team. I d and all that other A lot of other things that are related to Apple in order to do this . However, what we can do is she could do HTML five, and then you could run this embedded into a Web browser. As you see, there's not much that we really have to do here percent in just exporting it. Ah, you could do the same thing again with Mac and just run through. You got your game name here, You got your icon. You can bring in your signature versions, cooperates all that stuff, and that's gonna be the same with Lennix as well. You got your texture for match finally format, and you don't have a whole lot of options here, and then you're just gonna export. Now, when it comes to when knows, we have Windows Universal and Windows Death Cop. Now, these are two very different things. Windows desktop is actually gonna be, like an executed well that you would normally find out on on the web. Whereas Windows Universal is actually the Windows store, the Microsoft store. So unless you're put it up there, you do not need or want to use this when you just want to use the windows desktop. Once you have your Yeah, your preset Here. So what you want to do your template pick? I'm go ahead, Run through selector on any options that you want to do anything if you want to set on there. And now we go ahead and hit export projects. You can uncheck export with debug, and we don't want to put it inside of our same project here. But so you go ahead and export this wherever you want. I'm just gonna go ahead and create a folder here. Um, just for the sake of this, But you go ahead and put this and you should put it somewhere else. Not in your game water. Make sure you have actually debug off unless you need to debunk your game. In which case, anything that would show up in the council in our in our little I'll put council down here will show up and you will get the, um, debug window that pops up. So I'm gonna go ahead export with it just to show you go ahead and hit Save Now it's gonna create our execute herbal. Or if you're on OS is gonna create you. DMG you're on Lenox of pressure x 64. Now we navigate into our game game export. You see, we haven't X e and p ck The PC K has all of your assets, so it's got on your scripts. It's got your scenes, it's got your while. You're textures. Your everything is stored in there. We just run our execute Herbal you need to do is just keep make sure you keep both of these items together in the same location. Well, you just run the excusable and we have our game and you can see our debug window running in the background here so you can see everything running in the background, Um, coming up with errors. But these air just you know, like the hours that we see down here, There's nothing we can really do about those in the current state. You see, nothing is really happening. And normally when we win, we see it printed out down here. Winner. And we see that happening right up here. Now I think you see. Ah, if you're curious what these areas are, you can see these are CPP exceptionalist c++ scripts. So that's those errors are gonna be things related with, um, the engine at the moment. So that's nothing to do with your game? Well, if you export this without our debug and you think everything's fine, we have no issues. Then you can go ahead export without it, and we'll go ahead and do that again. I swore without save override it, and there we go. Now, would we run it? We don't have our debug menu and the game runs again just fine the way it was. And there we go. So there you go. There's how you can export your game regardless of what platform you want to put it on. You just go on in, go through any of your settings, export your project and you're good to go. So there we have it. We have exported our game. We've created our game. We've made touch binds in case we put this on a touch device or in case it runs on a touch device. And now you have all the knowledge to go ahead and create the platform that you want to create. You know how to create, um things with enemies. So you get hurt on sides and in touch from top. If you wanted, you could just set it so that can't kill the enemy. Of course, that's all going to come up to you and your own game designs. What? This? You wouldn't have the ability to make a game like Mario, though you would have to expand your knowledge a little bit and learn how to do things like power ups And what that were just again. Just gonna have your scripts talking with each other to communicate different things happening like we discussed throughout this course. But that'll do it for now, and that will wrap up this course.
30. Thank You: all right, everyone, that brings an end to our course year. But I do just want to give you two little tips for this just to avoid any potential issues and also a reminder for what you would obviously want to do in the future. For any games that you create on our winter screen here, you might want to add a button so that the player can play again or quit. Or if you have a multilevel thing, it was have some way or to load into the next level, changing the scene just so that you're not stuck on Ah you windscreen with nothing else being possible and then also, I would say, at a color racked here, which does the color rectangle change into black and drop your passivity and set that behind your lives. That way, your lives can at least be a little more pleasurable, especially since we have such a light background with it. But that's just too quick tips. I hope you enjoyed this course, and I'm excited to see your platform, er's and what kind of projects to work on in the future
31. Extras01 Boss Trigger: All right everyone, Welcome. In this video we're going to go over by request how to create a trigger for a boss events. So in this video, we're going to set up our, our whole trigger for everything to happen. And we're going to move our camera, pan it over to where our boss character is going to be. And then we'll pan it back over to our player character and let the user continue playing the game. So if you wanted to have some kind of intro to your boss, maybe hold the camera. At the end, show some texts on screen. Just let the players look at the Bosphorus, whatever it is you want to do. You'll be able to have at least that portion setup here. So you'll notice a few changes have happened here. And for that, the main things that you see are bottom three sections here, which is we're going to add a twin node C, come up here to your level, go ahead and add an adenine between a twin allows you, as he said there smoothly animate any property you see in the Inspector here over on the right. So anything that you see in here, your, you can smoothly tween it from one value to the next. We're going to add in another camera 2D to this, because we're going to switch to that one when we want to pan or camera over to our boss. And then we'll pan it back to the camera or back to our player. And then we'll switch back to our smooth camera that follows our player. And then we're just going to need an area 2D with a collision shape inside of it. And this is going to be our boss trigger. So you can go ahead and add an area 2D with a collision shape as a child of it. And as you can see here, I'm just using just a small, thin one and I'm just going nice and tall. Just to prevent any issue with our player somehow in any way not being able to jump over it. So we're making sure that no matter what happens, the player will collide with our trigger. Now obviously if you have a roof on your level, obviously they can't get any higher. And in this case, if the platelets are from here, they'll get to maybe here, then they should follow the way back down. So I shouldn't have to go any higher than this unless I built my level higher. So now once you have your area 2D, I've made my boss tutor. Have a collision shape covering your area for where you want your player to run into the boss. And you have a camera 2D attitude and a tween note added into your scene. We will need to do one I'm sorry, a couple of changes here and all of them are going to be the same thing. What's going to be doing it over multiple objects? So on our tween, one, go to our pause mode in the inspector and set it to process. Because what we're going to get to this trigger and everything is going to or not everything but our player here, it's going to pause. And then we'll move our camera come back and we'll unpopular that where a player can't run around or, or mess with anything. Wow, we're waiting rate. So we want, we want this to process when we do beta pause. And all that means is that the script or node is going to continue functioning while everything else pauses. We're going to do the same thing with this camera 2D. We're going to set it to process. We're going to set our area 2D here to process. Now even though this area isn't doing thing, we needed to process, that way the script that we put on it will continue running. Otherwise, that's going to pause as well. Now if you have music going on and playing in the background, I'm going to leave that as inherit. That way. It should inherit with the rest of your free. Which means if we fall off the level, the music is going to stop. And we're actually going to change that within our code that we just keeps on playing. And then we'll change back so that if you do fall off afterwards, the music will stop on a GameOver. Now what I want you to do is also go into your player scene, go to your camera and come on down and set that to process as well. All right. Because we don't want that to pause. You want that actually keep moving. Otherwise, we're going to come to the point where when we return to our player. And then because everything paused, including the camera here on the player, it's actually going to Jitter back, right? It's going to snap backwards a little bit and then it's going to continue smoothly moving to the player. All right, so once you've got everything set to process, we can actually move on to getting our code running. So go ahead and add a script onto your boss, trigger. Your area 2D. And we're going to go ahead and add a signal. And as you see here, connected to it. And that's just going to be on body entered. So we're going to check to make sure that our player entered because in your design, or maybe there's another design that you have going on, or maybe it interferes or intersex other objects or enemies or whatever else you have going on. So we're going to use this to just make sure that what we want to happen only triggers when our player gets, gets involved and they get in the way to go ahead and connect that signal. And will be left into scope here, right here, into our script. So on Bus trigger, we have our body and exactly like what I was saying here, and you guys should know how to do this. If you want, you can go ahead and do this already. I'm going to go ahead and type it in if player and body dot name. So we're going to check to make sure that our player is here and getting involved. So we can go ahead and actually print player triggered area, right? So if we were to run this now, you should see that popped up down there will come in. Now I have, you can see all my shapes here if you wanted to, how to get that? You can just come on up here to debug and turn visible colors and shapes on a, you will have to restart the game with the game is running. So now if I walk over here, you'll see there's my boss trigger there that I've set up. I just get that out of the way. Right. So you see that's my trigger. And soon as I enter it, as if our signal is connected and working properly, we should have player triggered area printed down here in our n, our output. All right, there it is. And you see, we haven't said anything else up, so we can just keep on triggering that. All right, so we know our signal is working and our trigger for the boss's working. That's good. That's a great start to what we're going for. All right. So if we start setting this up, if you remember, we need to, we're going to pause our tree. So we're going to pause the game. This is going to be the same way that we did when we did our GameOver, where everything pauses. I'm music and everything stops only after a set amount of time we're going to unpause. So if you remember how to do that, or if you want to take baton, go back to the script C, which did if it's been awhile. That's fine, but go ahead and take a shot at pausing the player, waiting for a set amount of time and then unpause so we can continue playing. So if you've paused and taking a moment to do that, if you've gotten it, congratulations if it's working. If not, I'm going to show you how to quickly do that real quick. So if player is in our body name, then what we wanna do is simply just get the tree. So get, treat, create timer or sorry, not create time or pausing first. So get tree dot, paused. And we can just set that equal to true. And then we will use yield and do get tree dot create timer. And I'm going to go ahead and set mine to for testing this. I'll say five seconds. I will be adjusting that later. And that'll be our timeout. So wait five seconds. And then will un-pause. Get tree dot equals false. Alright, so now once we get involved and we cross that line, our player and everything should pause. Wait five seconds, and then we'll be able to move again. And you'll hear that since we set our music to Asa process, no, we haven't touched our music. Get what? We'll go ahead and tackle that bisection next. So you see we get here, everything positives. We wait a few seconds, whatever you set in your timer. And now we can play again. Now of course, since our trigger is still active, we can actually trigger it again by going the other way. And we're obviously not going to want that. So when we un-pause the tree, Let's go ahead and disable our shape. So since this is on our boss trigger the script, we can just access our collision shape directly. So collision shape not disabled equals true. And what's that gonna do if you're, if you can see your collisions there, it's actually going to turn gray indicating it's disabled. Once it's disabled than it can no longer trigger, but it is still loaded in the scene, so you can always enable it later or enable it in the future if you wanted. If you feel safe and comfortable with it, then you could just Q at free and just completely remove it from the level. That's completely up to you. I'm just going to disable it. But if you want to free it from you seen, go ahead and do so. All right, so our music, so we need to actually get our music node. Now, I'm going to use PGM here. The second one was speed up for a question that I had for speeding up music. If you want to know how to do that. You can see ads that have the same thing here. I just adjusted the pitch to it and it just sounds a lot more sped up. Then our default music did. So let's go ahead and get our note here. So to do that, we just do get get parent. Because remember where right here and we want to go up one to get up to our level. Now what we can come down and access our music note here. So it gets node and we want to BGN AM, in my case. And we're actually going to set the pause mode equal to and we want to set it to process. Now way it does not pause when we get there and continues running afterwards. And when we un-pause it, we can go ahead and just set it right back to inherit. So if we run that now, everything should be the same. Only when we get over there. You'll see when our timer finishes, our collision here, our area through here is going to turn gray. Or if you're freeing it from me seeing it will completely disappear. And our music will continue playing throat and it will not stop. So our music is still playing. I can't move. Wait for our timer. Now it's been disabled. You can barely see that on this background, but it is great. And our music is continue playing. Nothing has happened. And we know it's set back to inheritance. If I go and jump off when this case the music stopped. If you want to loop that, if yours isn't looping for whatever reason, I can come on in. Music, I forget which one we're using. Quirky action is gone, we're using okay. And that tool, we're using wave. Okay, so this has updated. So now I've got both MP3 WAV or WAV file, both in New York. So what you can do is you can just grab it, hit the import tab up here at the top and you can turn loop on. I'm not sure why mine wasn't already looping, but say it loop and hit re-import. And now the music should stop. Once it gets to the end, it will just restart. And I just come down here, we see our music keeps playing. Wait a few seconds, our collision gets disabled. And if we jump off would know it's back to inherit because our musical stop when we get our demo. So everything seems to be working fine. We've got our trigger. Now. There isn't a whole lot. Now we actually have to do from here, aside from changing our camera and moving it around, right? So let's see. We can get our positions so we can move our camera 2D so that we can get it in the right spot. And we can actually what's going to change our smoothing. But we don't have smoothing on. Smoothing is off by default because we don't need it to. I don't know if we would write. So what we're gonna do is we're going to go ahead and set up our camera to move. All right, So once we pause the game, and what we wanna do is actually we're gonna do it before we pause to that, it just happens. We're going to go ahead and go up your treat and grab this camera note here that we have. So remember we want to get your parent and then get to node. And we're actually going to set that to our current. So if you look over in the Inspector, you cease to us just a toggle switch. So say true, false. So we're going to say current on this camera to true. After we unpause our camera, we're going to set the one on our player. Here we go, our player here back to true. Alright. So that's going to allow us to jump to arc, what are other camera and then back to our player. So if I were to select this one, you notice this one is where do we have it? Right here. And I'm going to come down here. So you'll see once I trigger, the camera should jump up because we'll be up here for a center instead of down here. All right. So before we pass, it, wouldn't go ahead and get parent and then get our node. And we're looking for our camera and going from level that's just B and C. So it's right near the top camera 2D. And we're x2 dot current equals true. And then when we un-pause and the game, we're going to do same thing, but we're going to get the player camera. So get node. And we get a P for player a want the camera inside of our player. And we'll just set that to current. Just remove that space there. So if your cameras in a completely different spot, which by default it will be up here in the corner. You should notice the change is should we rather obvious OMC see that my camera jumped up and at the end of the 10 seconds will snap back down to our player. And as he saw, there are a camera actually continued moving after the pause because we're still lagging behind from the smoothing feature. So what we can do to actually fix that is turn smoothing off on our cameras, on our player camera, and then turn it back on later. So right after we pause, Let's go ahead and turn that off. It's not that. There we go. We'll just grab our camera here again, the one that's on our player. And we're gonna set smoothing enabled to false. And we can enable that again afterwards, after we change our camera. So after we set the camera and our player back to true will enable that again. And that should, that should help with our jerkiness. Okay. So you see so you saw there my cameras, I jumped down. It didn't jump back and then smoothly move in. It just snap back down. And that is because with smoothing off our cameras, a snap right back to our player is, instead of continuously smoothing out or moving over. So once we set it to true, our smoothing is still disabled. So it's a snap for it back to our player. And then after we snap that to the player, is when we're turning, smoothing back on so we can get that nice smooth movement that we add. All right, we've got a lot going on in this one. And this is just getting our camera setup. What else do we need to nearly anything else in here? I don't think we do aside from the actual movement of our camera. And I'll go ahead and well, we can do that next time. We'll do that in the next one because this one's already getting a little long. So we'll take a look at tweening our camera and sliding it over and bringing it back and the next video. But for now, you now have a boss trigger that's functioning. We got the pause happening, we have our unpause happening. We've got the music that's still playing and are shaped. Our area disables itself so we cannot keep triggering it. All right, not to do it on this one.
32. Extras02 Tween Camera: All right, everyone in this video, we're going to go ahead and use the tween nodes to animate our camera to mostly slide smoothly. Slide from our player over to our boss will be shown, and then we'll come back to our player. And then that's when of course we'll go. We've already said it here in our last video of going back to our players, Cameron, restoring the smoothness to it. All right, so let's actually handle the time that's gonna take place right here, right in between. And we're gonna do, we're gonna create a function called tween cam. This. I want to set it right here and we're going to call it. And just before we have our yield to pause our script. And I think what I want, I want five seconds for it to move over to the boss. And I think I want five seconds for it to come back to the player. So it'll be 10 seconds total. So I'm going to change my yield here from five to 10 seconds. All right, so let's go ahead and get started with this. So the first thing we're going to need is we need our tween note here. So instead of writing this long thing out over and over, I'm gonna go ahead and just create a variable called tween. We want a variable not a car, var tween. And we'll set that equal to get parent dot, get node. And we're just gonna go ahead and grab our tween. So I'm just going to hit up. And we're going to look for a real tween. And this will just allow us to get to it a lot quicker. So we can just do tween like that. And of course we can do that to get everything that we need. And instead of typing out the whole get parent gut node tween and then everything else that comes after it. So the function that we're actually going to call on our twin node is called interpellate property. So if we were to actually take a look at that inside of the documentation here. We don't want to method, we want a property. Says she, this is just going to have a lot of arguments attitude. So we need to know what we're training loops. So we need to know what we're tweening, what property, what it starts at, what it ends at, how long it takes to get there. And then we need a type, which it's like a curve, has to move it. You can play around with that and decide which do like yourself personally. And then again, we have the easing type. And of course you can always add a delay after that as well if you would like the delay by default is 0. Alright, so let's go ahead and tackle this. Let's call it tween interpellate property. Now again, our first item here is an object. And to make this a little easier, I think I'm going to go ahead and actually create one more variable cone camera. And him, and him Kam, we'll call it that for animated camera. Just so we can kinda keep things apart. And I'll go ahead and I'm just going to grab that node which we had already happened up top. Here. I'm just going to go ahead and grab that Smith things a little bit easier. So the first thing is our animated camera. And then our second property, or a second argument is a property. Now if we look over in our Inspector, what we want is the position. And you can see you just hover over that its position. And that'll take that in the form of a string position. And then next is our starting value. Okay? So for our starting value, actually want to get the player's position. I'm going to grab what we already had a job. So we're going to get our player node dot position because we want to start at our player said we can move from the player over. And then we need our final position here. And when I am actually using for this is I am, I know what a movie on state going from our starting position, I'm moving over a set amount which I'm using 2900 on our x. Now you can always take this and add just directly to your x-value a set number if you wanted. For example, if I were to come in here. Since we're working with a vector like this. So we have x, y like that. So in my case, I don't want to move on My wife. And if you wanted, you could just grab your players magician WX, right? Or actually, yeah, we're good that way, so you just take that and then you could always add onto it or subtract from it if that's what you wanted to do. Since I already know where I want to move mine, I've actually just going to move mine to a set number. Now for you, this, obviously this number is going to be different completely depending on your level, your game, and how you want to set this up. For me. I'm going from my player's position and I'm moving over to about 2900 for my final position. And also, if you will, if this is a little hard for you to read, moving left and right like this, you can actually just come in and between properties, hold Shift and hit Enter, and just kind of break it up like so. If that's easier for you to read. So we can actually just do something like this. I know some people find this a lot easier. And which one are we on? Duration, okay, So I want mine take over five seconds. So somebody with this a lot easier for them to read. And I know others to still want to have a really long line that extends. In this case, I personally like to keep mine. If I can just not go past this one line here in our editor, that's a personal choice vine. Now, at the end of the day, this doesn't matter. It can go all the way over if you wanted, if you had the space more. But and again, personal preference up to you if you want to split that up. All right, so I've added in my duration here, which is five seconds. My next one is an easing type of leave. No are trends this entity that keeps pulling me back there. So to do this, we're just going to get tween. And as you see, we start typing trends. And you can use any of these options. They're all completely up to you and how you want to do it. I'm going to use quaint and this one I think if you want to go through mess around and take a look at all of them, you can definitely do that. So after that, that's as Liza squared. Technically, two more options were rodent going to use one more. And that's tween dot iz. I'm going to use an out. So if you wanted to move instantly, then you do not want to ease in. And if you want it to smooth towards the answer, come to a slowdown before stopping. You want ease out me, I'm going to go in and out myself. Most cases, that's what I personally go with. So those are all the arguments here, right here that come into place. For a tween. Like so when you want to interpolate a property, now there is one more opsonin here, and that is of course, if you want to cause a delay before the tween begins, I suppose. I'm not sure why you would really need to, but if you do, after this, we do have one more thing though. We do need to tween and Starks, so we need to actually start our tween. Otherwise, nothing is going to happen even if we call property. So if we go ahead and take a look at this, we should now cause this camera to trigger. Remember, I am calling our tween cam function up here before I wait for my ten seconds. So in this case I think I'm just going to set that to five for this test since we only have one movement. So let's go ahead and go back and take a look at this. Boom. And we share movement. Goes all the way up and we just snap back after that five seconds and we can move again. So that's working fine. Our position is a little weird. Why is that? Our starting position? Because I set my Y2 to a 0 and that's why honest not what I want. I'm just going to take this and set this to our Adam cam dot dot y as our cameras should already be repositioned or will be at least repositioned. So if we go ahead and take a look at that again, That's it. Fixed that moving up and just move to the left. Then it snaps back. All right, so we've moved over. Now we need to actually move our camera back. So I'm going to go up, we're gonna go ahead and cause a yield. And created another pause here with gantry, create timer. And this animation is taking five seconds. So we're going to call site for five. Wait for the timeout. And now from here to add the bottom here, I want you to go ahead and create a, another tween, interpellate the property and move it back to our player. Go ahead and take a shot at that and remember to start between afterwards. And if you can figure that out, awesome, great. And if not, if you haven't promised struggling, come on back and I'll show you how to go ahead and set that up. Alright, so we want to set that up. I'm just going to copy our interpolating from above because it's almost exactly the same. The difference is, is we're actually going to set this R 2900. Actually go back to our player position here. And since we're going to set that with our Y as well, we can actually just set it to our player position, right? And then instead of, and that's for R2, right? So our starting position here, we're actually going to just set that to our cameras current position. Instead of our player's position to start with birds going to be our cameras position, current position, and then we're going to move it back to our player. So when we're moving from our player, we start at our player position and then we move it away. And then we want it to move it back. We start at our camera's position and we move back to our player's position. And again, remember to start between afterwards. And let's go ahead and take a look at that. And once we touched this, we should move over 4 for a total of five seconds and then we'll come back for five. Oh, I just realized it when I have an issue because I need to change this back to 10 seconds. And my body entered function because we got five seconds ago there and then five seconds to come back. So that's ten seconds total. If you're wondering how I got that 10. So we're gonna move five seconds over and then five seconds back. And then I can move. All right. So if you're wanting about that little jerkiness in the camera, you see once I when I NesC trigger that. So you saw that instant move hour. We're going to actually fix that by moving our camera up in our trigger. So before we even mess with the tweening, we're going to let's see, where do we want to put this? Let's go ahead and let's just set the threat of him. That way it shouldn't get involved with anything in a sense, we trigger it will move the camera. All right. So let's go ahead and grab our camera. And we'll set the position equal to our player's position. So we set our camera efficient to the player position. I'm segment up at the top before I set it as current. That's probably the only important key thing here. So we said it before making it correct. And now if we go back, you'll see we won't have that jerkiness happened to it. We did get a little bit at your condition there. So unfortunate. So what we can do, what can we do about that? Let's see. Between setting our position and setting it to current was go ahead and wait for an idle francs. That's going to be yield, get tree, an idle frame. And that's where it's going to wait for the next frame where nothing is happening and then set the camera. So hopefully that'll help out a bit. Okay, So that helped out a bit. It wasn't quite as jerky. Alternatively, you could, instead of going for an idle frame, if you wanted, you could do another small timer like maybe 0.1 or something just really small, just to cause our current here to wait a moment. Edge you see that helped with that jerkiness a little bit as well. So if you wanted to go this route with the timer, then all the votes coming in and tweaking your numbers. If you want to go this route instead of the idol rho. O, in that case, you see that also Pauser are putting a delay in our pause here, which isn't exactly ideal. So you can also mess around with trying to rearrange these. Now if you wonder how I moved to line up and just hold Alt and use the arrow keys. So we'll see maybe, maybe this will work better if we pause it, then have a brief moment, right? Right, and then set our camera so we'll see if that helps. All right, so there's all different little tricks that you can do to China. So it's just kinda like tweak with that jerkiness. There's just all about playing around with it at the end of the day and tweaking numbers and getting things to work the way you want them to. But with that, everything is working just as we need it to be. Now you can imagine if you want to use this as a boss intro, some skin turned my shapes off and we start that real quick. So you can imagine if you wanted to do this for a boss intro, right? We come over, this triggers, camera moves over. Maybe we see the boss's name or we see how intimidating the bosses for a moment, and we'll come back to our player. And now our player can begin their boss, the boss battle, right? So we now have our camera setup, we have our trigger setup. Now all we need is a boss to work here. And we're going to see ago, see about trying to put a couple of different phases in here, right? That way we hit them, then maybe you changed it into another phase. Mean, maybe he gains a second attack type. And then maybe we had him again and then he dies from there. So maybe it'll be like a two hits or maybe three hits to get into that. Maybe we hit them twice and then that triggers them to get a new attack. And then of course, the next one after that, our bus will be killed. So we'll figure something out to go around with that. That way it's not just Oh, shows up and he starts doing one thing over and over like a normal enemy, right? We're make them a little interesting, right? That'll do it for this video. You've learned how to use the tween node and how to interpolate a property to animate anything that you see in the inset inside the inspector there. Without having to use an animation note or an ad or animation frames or anything weird like that. Now, if you can use a tween, it's usually suggested that you do use it over doing an animation. It's just, it's smoother. It's from what I understand, it's also better performance wise during this. But of course, at some point you're also going to need to use animations like we do with our player for our sprites and all that. But before going off on a tangent, That's it. We got our setup here, ready to go. And I'll see in the next one where we can start looking at our boss.
33. Extras03 Introducing Bosses: All right, everyone in this video, we're going to go ahead and take a look at giving ourselves a little intro to our boss fight. So if you want to have, maybe you have some textual up on screen or maybe some audio to play, some voice-over. Whatever you want to do to introduce your boss. This is going to be how we're going to go about doing that. Alright, so to start off, what we're going to need is a boss, of course, for us to use. In this case, I created ones are seizing the zombie that we have inside of our textures. And they're inside the player folder. So you'll find the zombie there. So if you're not using the zombie, you can go ahead and use the zombie for this. If you are using the zombie, then you can use whichever other art you want to use. Or if you have something else already created, you can certainly use that. Alright, and I just went ahead and created an attack and a Mason here and idle and a walk. And of course, attack does not loop and IDO and walk do. Alright. And for our hip boxes here, they're exactly the same kind of setup as we have with our walker here. So we just have it the kinematic body and animated sprite collision shape so that we don't fall through the world. Which I should actually move down a bit. Now that we have our feet down here. Oops, that's the wrong one. I want this one. Move it down a bit there. I have my area with a collision shape inside of it for the enemy damage, which is our little spot up top here when jumping on the boss. And then we have our area for the player to take damage, which sorry with that extends out to the side here. And of course, you know, is adjust that to whatever you would like in your game. And I'll go ahead and just save that. So again, that's a kinematic body 2D, an animated sprite, and a collision shape. As children of that, as well as two areas as children, one for enemy damage, one player damage, and each one of those with their own collision shapes. Now we won't get into the scripts in this one. We'll save that for another video where we start going into as states and setting up different things for Boston not student. The one thing. Now what I'd like you to do is go into your animated sprite and makes sure in the inspector idle animation that's playing right at the start. That way we don't get any weird looks and they'll just be standing there. So if you need to go back and reference that, you can reference your walker that we previously created. And now for our level. I'm gonna go ahead and instance in my zombie boss where I would like to put him somewhere around here. I think, good. And what we're going to see next is our little introduction to our zombie or our boss. If you're creating your own boss in this. So I'm gonna go ahead and add a sprite, not an animated sprite, just a regular sprite. And I'm going to call this zombie text. And I'm going to assign that to the zombie P&G here. And as we'll see, that's just some text here that I've saved and brought in called the zombie. And let's just adjust that to a vote three to six. Now if you want to create Joan, you most certainly can do that. There's no harm to it. But I'm just going to use this. It's simple, it gets the idea across. And I think it kind of fits with the rest of these graphics here. Whereas this comic, simple, rounded, nothing extraordinary or fancy. And attaching to this zombie text, I'm going to give it its own animation player. All right? And with our animation player here, we're going to go ahead and just come down here to the bottom of your screen. Animation section should pop up. If not, you can click the animation button down here. But if it has popped up, and then right where my mouse is circling, go ahead and hit animation and new. We can call this text up here. And what I'm gonna do is I'm gonna make this five seconds long, because that's how long it takes for our camera to get over there. And then times actually on the right side at the end, right over here. So I'm going to change that to five seconds. And I'm going to jump right to the end of my timeline. And before I do anything else, I'm going to click on zombie text. And I'm going to click the little key in the inspector right next to scale. And I'm going to use the Bezier curves. That's the skin to help curb site curving the animation to outbid be a little smoother instead of less. Snap, I guess we could say. All right, and then all the way down at 0, I'm going to set these to 0 on the x and 0 on the y. And 0 hit the key to lock that in. And I think I don't want this to move until maybe the first second. So I'm going to set this to 0 as well as after scrolling to one in our timeline. And hit are key to lock that in again. There we go. Make sure that it does show up on your timeline. That way you don't end up frustrating yourself if it doesn't show up. So go ahead and click again. Maybe we're a little off and you didn't notice. And then from here too, Let's say three, we're going to go to, I'm actually going to match this to my final result, which is 0.3 to six on my x and y. Now the reason why a muscle setting this early, if my set there we go, that's a little off. Is because actually wanted to enlarge quicker over that two seconds. But then what I'm gonna do is I'm going to come to the four seconds here and I'm actually going to expand it and make it larger. So in kinda get like that bounce-back effect going on. So I'm just going to come here and set this to 0.35, x and y. Now you can always tweak these numbers or give yourself a little guesswork. You know, it's kinda play around with them to find something you like. And if I hit the play button, we can get ourselves a little preview. So we get that. That's slow, like little balance going in. And for me, I like that. I think I'm going to stick with that. I'm going to pull my bar on the timeline here all the way to the beginning just to avoid any issues or nothing playing or whatever that might happen. You never know it's software can always bug out at some point. So to check these placements, I'm actually going to increase this actually increases up on the timeline all the way back to the end. I'm not going to play anything, so it should just stay locked like this. I'm going to jump in game. I'm gonna go trigger our camera movements are our trigger that we set up last time. And we're going to see how that looks on my screen for placement. All right. Our camera moves over and I think that placement is fine. I think I'm going to stick with that if you want to make adjustments, sewers and certainly again. All right. I'm just going to stop our preview there. And I'm going to move into our boss trigger script here. So you can just hit that and it'll pop up in your editor. And we're going to need two things. We're going to need to get a reference right? Animation player just to make things a little, a little quicker to get done. So we're going to say var text. And we'll set that equal to get parent.value DataNode. And we're just going to set that to the zombie text slash animation player because it is a child of our zombie text. Now if you did not make it a child, then you could just do animation player in here. So now that we have that, I'm going to do text, anime, play, text up here. And let's take a look and see how that looks. Now remember I set mine to be a 5 second animation. So that lines up with our camera taking the five seconds to move over there. If we take a look. Oh, there's the issue of bringing it up. So I'll just go to my timeline and scroll it back to 0. And which jump in and take a look at that again. And then our animation player is not playing. Why is that? That's right. One thing we've got to do, It's not playing because our pause mode here is actually inheriting, so it's pausing as well. We want to go ahead and set that to process and end just to be safe. Let's set our zombie texts also the process. And we go, We've got to change that. So that was pausing with a camera, so it wasn't actually going to play at any point. And I just jumped off the world. So let's go back. Alright, and so it should work now that our stuff is not going to pause, it's just going to keep functioning and processing. And there we go. So I might want to move my text over a little bit and then pull up or delay it a little longer. I don't think I'm gonna take a look at delaying that a little longer. See how I like that. So I'm going to grab my two keyframes here that I haven't One second. Just going to grab both of those. And it wouldn't move that up to two seconds. I'm going to hit play and I'm going to try that again. See how that looks now. Well, I almost fell off their stuff away that for an extra seconds of delay. Alright, I think I like that a little better. So I'm gonna go ahead and keep that. Now. Obviously when everything un-pause this we come over, our text is still here. So if you want it to be there, That's fine. You can keep it there. You can go ahead and move it in our layer order. So if you wanted to just grab this and move it up above the player, why did oh, because it's behind the background now. So that would cause a bit of an issue there on our render layers. Alright, so if you wanted to do that, you can actually come down to the z and x. Can you, are you guys able to see that you cannot? Because this in the way here we come down to Z index over here. And this is the order that your graphics are gonna be drawn in. So since everything is set to 0 in our scenes for here, the ordered everything is in here is what's going to make that decision. But if you wanted to say adjust that, where is our game? Notice. So if I just come back here and we replay that, and I'll show up, and then it will stay. And you'll notice that if you do want your texts here to stay, since we can't put it behind because it will be behind the background. If you come up, it's in front of our player. What you can do is you can actually just come over to the Z index and adjusted. Then we change that to minus 1. You see now our players in front of the text. So if you ever have any weird layer issues, you can just use the Z index there were set index to make that adjustment. All right, so now our text is here, but what if we don't want it here? What if we wanted to disappear afterwards or disappear when our cameras starts going back towards our player that will use us have hey, the certain little intro is here, cool. Boss introduced and then make it disappear so it doesn't distract the player while they're having their boss fight. Well, we can just head back into our script and after our yield, right? So before we were about to move our camera backwards, backward layer, we can actually just get text, anime, so our animation player. And instead of play, we're actually gonna do played backwards. So we're going to play your animation backwards. So it's going to go forward for five seconds, and then it's going to immediately go backwards. Then it's going to look pretty seamless as an end result. And with the way we got to set up, our camera's going to move over, our text is going to appear. It's going to have a little bit of a bounce to it for a second or two, and then it's going to disappear again. So let's take a look. And there's our text. A little bit of bounce and disappears. And now we can continue with our fight and it doesn't distract. And since we have nothing set up, we can just kinda stand on our our zombie here I was under the bus. All right, so that's how you can go ahead and create a introduction to your boss. And of course, after all of that is done, if you wanted, I can come down here and you could completely free up Q3, your animation. So of course we would have another year yield down here. Just to wait another five seconds because we don't want it to disappear to Salem. We want to wait until the animation is finished. And then we can cue it for you. But I'm not going to coupon free. I'm going to leave mine just the way it is. It's not going to be too much of a difference in this situation in terms of resources being used on the computer. And in, I guess in the next video, we'll go ahead and start putting a script on our zombie boss. That way he can move around, have gravity effect them, attack the player. And then we'll start looking at our different states. So that depending on his health, He's going to maybe do different kinds of attacks.
34. Extras04 Boss Code: Hi everyone. In this video we're going to go ahead and we're gonna take a look at how to set up a boss fight. Sir, I'm going to give you all of the basics to Guigo and how you actually code. Each phase will be completely up to you as everybody's going to want their bosses to be different. But I will show you how to make things happen, how to make your boss when he moved towards your player or away from your player. And how to use something like distance from your player to make things happen. And before you think something like that just sounds boring, we can take a look at an example of that actually from an old game here called Sonic. So we have our boss intro where he comes in. And I'll always doing is he's just playing an animation right with the school and back and forth. And he's got a collision shape on this to hit the player. But in the meantime, he's just going left and right and turning around. So that's all he's doing. Now, whether or not he's using that for base off of actual distance are not as completely different. I don't think he is. I think he's just programmed to go left and right and left a certain amount and then turn around and go to the right a set amount. But in this case he's got just the one phase, whereas you can have multiple phases if you want. And he just got decide how you want something to go. So in this case he's got one attack and it's just a swing ball back and forth. All right, So if it's set back into, you got 0 here, you're going to go ahead and put a script on your zombie boss. And we're going to need some of the Bobbi basics here. So we're going to need velocity, speed, and gravity. Because we don't want our marine need a velocity Sweden order to move ever in a gravity to make sure he doesn't float away. Unless you don't want gravity and you're creating a flying bus, then of course you won't need that. So let's go ahead and put that in. So velocity is just an empty vector, two u of 0, 000, speed, I'm going with 200 and gravity IVS 500, It's fine. He's never going to be jumping or flying around in this case. So probably even go with much lower than that. But when you see if it affects it, our adjusted if not, then that'll be fine. It's a boss. So our boss will need life. And we'll set that to two. So when he has two, you'll get hit, go down one. And that'll give me a chance to go into a second phase. And then when he gets hit again, then you'll be dead. And while he'll go into his dead phase, speaking of our phases of our state machine, let's go ahead and create a variable called state. Now, when we create state machine state is usually in all capitals. It's completely up to you if you don't want to, of course, but that's how I've mostly seeing them as always, we're stapling and caps. Now to get a list of our states were gonna do and eat them. Like so. And we'll call these lab idle. Being do this all on one line if you want. Phase 1, phase 2, and debt. And in our reading function, we can go ahead and set this to what we wanted to we started with by default, which would be idle. Now for setting this, you could do state equals idol like this. Or you could also write it as state equals 0 because idol was the first one in here. So does our first array index, right? It's our first set here. So 0, an idol are the same one and Phase 1 of the same two and phase two are the same. Three and debt are the same. I prefer to actually write it out. Now we're just looking at the code. I know exactly what's going on. And I don't have to remember what order all my states are written in or scroll up and take a look at the script again. I'll just notice from looking at it, was so which of those two you prefer is completely up to you. But we won't actually need to write that in. And this, for this because we're actually going to go to, we're going to create a function called set state. And that'll take in a parameter of new state. And that's just going to be our state. Equals new state. So now we've set state whenever we need it. And we can go idle just like that, and it'll work. Or you can set it as 0, like so. Now whichever one you prefer. Yeah, it's, it's not really gonna make any difference here. I me myself. I prefer just doing again, writing out the full Bird. All right, we're going to need a physics that running physics. So we're going to create a process function. And now we're not pass, we'll do them. Move in, move in slide. Put an R velocity, and we'll set our APP vector to dot. This is all stuff we've done before. I'm gonna do apply gravity. And I'm going to create that function next. So I'm just going to pull that in from our older script. And we've already got on our player. So if we're not on the floor and we're going to be adding gravity to form y. All ready? Go ahead and save that. And all that's really left is dealing with our life and changing states and our actual little machine to control what happens during each First Dates. So let's go ahead and attack the state section. Since I'm assuming that's mostly what you guys are going to be more interested in. Let's go ahead. I want to just call my boss. And I'm going to go ahead and just call that up in my process functions. All right, so what we're going to use here is called a match. And a matches similar to using an if statement, if you only want to compare 11, comparison, right? 11 thing that must be true. So in this case we're going to be matching state. And then underneath here we just got to put in our state, so we'll go idle. I'm going to pass phase 1, 2 and dead. So this is say, this would be the equivalent of saying if state is the same as idle. So if our state is idle, do this for our status phase one, do this if we're status face to do this, and so on through all of the states that you have set up. So matches just a much cleaner way of doing it when you only want to compare one item. Now if you want it needs compare multiple things. Then you can just use an if statement and just keep it all in one line. All right, so inside of our idle, simple, we just need to check if our animation is not already blanked. So if not animated sprite dot is playing. So if our sprite, we don't have an animation playing, then we'll go ahead and play our animation idle. Then we create them already. And we will go ahead and print. Let's say current state is idle, just so that we know, right? And I'll go ahead and do that down here as well. Current state is phase one. Current state space too. Current Status dead. All right, so we have idle setup. We don't really need anything, we just need to stand there and be idle. I guess we can go ahead and set our vector two, or sorry, velocity two is 0. So a vector to 0 or vector 2 000, whichever you want to do it. And we can put that in just to make sure that we don't have any bugs that causes our character to you. For, for some reason our boss moves around. We just want to be safe. So we're going to put that in just as a safety measure. And I'm going to go ahead and put that inside of our debt as well. Actually, we won't need that in our dead. And we can just call our Q3 and make our boss says disappear. Now obviously if you want to have like an explosion or something with your boss, maybe you'll be playing through those animations and whatever else you want to have going on here. So let's go ahead and take a look. Oh, we're not actually setting we are setting our state there. Yes, So that's all we're going to meet there. Let's go to go into our boss trigger. And inside of our trigger here after everything is done, our collision sheep has been disabled, our music and everything has been resumed or smoothing is said, cameras return. We can go ahead and get your zombie boss. So you can do good parent dot get node and zombie boss. And we're going to get the state property of it. And we're going to set it to our zombie boss and get the phase one. So we're setting our state to phase 1 with this. Alternatively, you can do this with, if you don't want to write out good parent dot get note every single time. A tip is, you can do the dollar sign here pair of double quotations, and you could do two dots, forget parent, and then do slash zombie Voss. Since we're using Git parents once, we only need the two dots. Now if we had to use Git parent twice, we would do it like that. But that's just something to point out to make this a little, little more condensed. And if you want to condense a lot more, instead of going through all of that. Because now, now we can just do voodoo dot set state because that's on our bus. And then call set state. And we can pass in our zombie boss phase one. So you could do it like that as well. However you want to do it, that's up to you. I'm just going to use the good parent get node method here just because I already have that written out. So that'll set us to phase 1 after our boss has been triggered. So when we start, we should be in, I don't know, good level one and play. And we'll see in our output current state is idle. So our bosses just standing there waiting for us. Aaron, as soon as we see what our trigger here is over, we'll see down at our output that our bosses now in phase 1, which of course is where your attacks you're going to start. And then we go Current Status phase 1, and we're good. Now obviously nothing happens during phase 1. You've just got stands there for now because he's got no code telling them what to do.
35. Extras04 Boss Code Phases: Alrighty, So let's go ahead and tackle Phase 1, where we're going to have him move towards the player and away from the player and completely based off of distance. So what I'm gonna do is I'm actually going to comment out that print statement just so it doesn't cover too much of our screen inside of our output goes, I'm going to show you how you can get distance so you can decide on yourself what numbers you want to use with your game. So we're gonna go ahead and print our position dot distance two. So this is the first position is going to be us. And we're going to get the distance to sew from us too. And the argument we pass him, which is our player. So this is an example where we can go like this to shrink it down and position. So I'm gonna go ahead and just print that out. And that'll be our phase one for the moment. Now, I know what numbers I'm going to use, but maybe you might want to use different numbers. So we put this in, we head on over. And you can see in our output the numbers are changing so you can decide what kind of numbers you would like to use yourself. And once you've decided, head on over back into your code, and we can actually start putting this out. So I getting this coded. All right, so to do this, we're going to check if position this dense. Why is this? You've got to be indented one here we go. If position, distance to our player position. So I'm going to use 200. So if where there are players more than 200 away and our distance to a 100 distance away. Then I'm going to set my velocity to have my boss go towards my player. So I wanted to do velocity equal to position dot. Now instead of distance, we're going to use direction two. And this will actually give us, instead of giving us a single number like distances, this is going to give us a vector to, to tell it, to give us a direction to go in. So it's going to give us an X and a Y. Let's see, they're going to be a positive or a negative. So we can use direction too. And we can go ahead and get our player again and our player's position. And what we need to do from there is we need to normalize it. So that if f, Let's say if for example you have a flying boss and they go up on an angle. So let's say a top left or top right, then they're actually going to go at this same speed as if they just went straight up. As if they had just gone straight up. We're straight to the right. This way, everything's consistent. If we don't normalize this, then they'll actually be moving faster when they go on an angle. Now, you might want that, you might not. But we're going to take that and then we're just going to multiply that by our speed. All right, so let's go ahead and take a look at that. So this will trigger will enter Phase 1 and then he'll be walking towards me. Now we don't have anything else setup, so we're just going to keep walking to me no matter what. Now the reason it didn't walk, the reason why that's not going to change this because we don't have any else telling them to stop moving. If he's not or if he's closer than 200. So we can go ahead and put that in real quick. So we'll just go ahead and do an else velocity vector to 0. And just like our idol. We can go ahead and player idle animation. And now what we're gonna do here inside of our phase one is Brasil. Need our animation Player 2 or our animation to play. So animated sprite dot play. And we're gonna play our walk animation. And we actually need to make sure that our sprite is flipped in the right direction. Obviously adds only going to matter in certain situations and some bosses, where maybe your boss is stationary, but you need distance to determine other things. You may not need to worry about flipping your sprite. What I'm going to go ahead and flip this, which if you remember, our sprite initially faces to the right. So it has to be linked in our interface and left, some flip is going to be true here. So what I'm going to set it as and, and we just go ahead and get it. Come in, we trigger it and we go into phase one. He's going to walk towards us. And when he gets close enough, he said just stop. There it goes. So now he chases our player. Now see we don't have anything else that up there, but you see now follows our player and we're good. So now let's get it. If our position is very similar to this, it's going to be an else-if. And we're going to say if r is less than 150, and this is going to be a negative speed. Now myself, I'm going to also multiply my speed by two by sticking to inside these brackets here. So I've got negative three times two. Our flip is going to be false. And that should do it for that block there. And now you should walk towards us. And then if we go towards him, he sit back. We're not back off him turned around completely, so he'll run away from us if we get too close. So obviously if you wanted to, you could use something like this for creating a range enemy. Because obviously embrace enemies going to want to keep their distance from the player. So that's something that you incorporate into your enemies if you wanted a special entity type. All right, so we have that all set up. Now, Phase 2, obviously, you would do whatever else you want to do in phase two. So if you wanted something similar like that, you can do that. If you wanted a different attacks. Let's say. We could do, would you randomize? So we can always randomize number because we have to randomize the seed. Otherwise we always get the same number. So we're going to randomly select between two attacks. So var num. And we'll set that to a landing the random integer. And we'll set this to modulo 2 or percent two. And that's going to tell it to pick between 02. So we're always going to get numbers 0 or one. But I don't want that, so I'm going to add one to it. So that's gonna give us either one or two as a result. And now we can easily just go ahead and do maps. Attack, numb. Right? And go. Why? Franks? This is attack 1 and 2. Print this is attack two. Alright, now obviously this isn't going to do much if we don't have a way to enter our face too. So let's go ahead and take a look at our life system nor to change our phases. So let's go ahead and create a function of x or long creative function. We need to connect our enemy damaged area. And we want body entered. Connect that to our script. And it's going to be all the way down here. I'm just going to highlight that hold Alt and use the up arrow key to bring it up. Alright, so we can do our initial check, of course, which she actually used to by now, our player, player in body dot name. And we're going to do body dot enemy. So if you remember what this is, this is from our normal enemies where we jump on them and we bounce off. So we're going to do this so that we don't jump onto our boss. And then we're just like standing on them awkwardly. Thanks, So we do that. And now we can simply match life. So if we have two health, if our boss has 20 else still, then we're going to do life minuss equals one. So we're going to reduce one, subtract one from our boss. And then we're going to set state to face two. And then if we had one health, then we're gonna do our life minuss equals 1 and set state today. All right, so now when we jump on our enemy, we should, we should have our trigger first of all. So we'll be an idle state, then will trigger the boss fight, have our intro. That'll turn sediment, do phase 1, where he'll be chasing us around because that's where we got him up your code to do. Rather than doing any attacks year. I then would jump on his head and will trigger life here. So which will make this shorter here. He'll have to help. They'll lose one and go down to one health and will change his state to face to where he'll be selecting a random number to determine which attack he does. And then of course, if we jump on his head again, he should enter the dead state and free himself from the scene. So let's go ahead and take a look at that, save that, go into our level. And of course we're hurting the player. You just gotta go ahead and set that up as well, just like we did with our walkers. So player enters that area and just do what's called the HRM function. Honest, boom, AC. Now he's selecting between attack 12. He saw he was still walk away because we didn't affect his actual velocity when we change them into phase two. So if we wanted, we can grab phase 2 here, come down here, and just call that. And he'll just stop walking now. And back on over to our player. Follows us, runs away from us. If we land on them, we didn't get our bounce off, which is can there we go?