Making a 2D game with Godot in less than an hour

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so right there on the screen is this is the homepage for the get-down engine it's just Godot engine dot work I should let you know that there's some disagreement as to how to pronounce it I've heard both Godot and Godot I was a theater major so I'm gonna say good too but I've heard that the people who made it actually call it Godot so I might be wrong but why are we using this it's a really cool engine a couple of things about it I'm just gonna open it right here for one you'll notice it's already open it took about four seconds which is something you can't say about a lot of game engines but if I just might give you a little preview but we're gonna make actually a couple things about it it has built in 2d and 3d functionality but unlike a lot of other engines the 2d engine and the 3d engine are actually separate so unity and unreal you might think they can do 2d and technically they can but it's really just like 2d that's being projected onto a plane with a camera that goes right over it so you actually have a separate 2d engine in Godot which is why a lot of 2d game devs like it a couple of other things it supports a lot of different coding languages c-sharp C++ and it has a built in language called GD script which is very similar to Python and if you're new to coding Python is a great language to learn it's very easy to learn very easy to read and write there's anybody who's like brand new to coding here or maybe never done very much of it okay so python is a great way to go GD script is not exactly like python and we can go over some of those differences later I'm not an expert myself but I can spot some of those differences for you also Godot is 100% free and you might be thinking unity and unreal are also free and that's true until you start making money selling your games so Godot is actually released on the MIT license it's 100% free it's even open source so you can actually crack open the engine and you can modify it and make changes to it and that's why certain industries like at least from what I've heard the casino gaming industry is really interested in it cuz they don't have to pay any of their profits to companies like unity or Epic Games which was unreal plus you can extend the engine however you want so yeah that's good Oh in a nutshell want to close this if you bought I've not bought if you downloaded Godot that would be a good time to open it this is where to start a new project there's a series of videos on YouTube or someone I guess who had a video that blew up and they just said that Godot engine is objectively better than unity and he later posted another video saying look I was wrong here's my nuanced version of that opinion but then he said that godot's mascot which is this little robot is objectively better and I do agree with that all right so once you have Godot open and again it's a tiny program I think it's less than 50 megabytes I just click new project and you can call it whatever you want I'm gonna call it platform game and you notice it's telling you to choose an empty folder so I'm gonna browse my hard drive and I actually have a cadeau folder already and I'm gonna select that folder and it's telling me choose an empty folder I can just hit this create folder button so it'll make an empty folder with the same name super handy the green checkmark means you're good to go and hit create and edit okay so when you hop in there it looks pretty much like any other game engine you can move around in the 3d space but we are going to be using two DS so up here and these different tabs go ahead and click 2d and you can use your mouse wheel to zoom out a little bit and this is your scene view this is what you see in most game editors you have your x-axis your y-axis and this little blue rectangle is your it's like your viewport it's the size of your game window so when you play the game this is the area that you will see now that we've done that we need to create our first node Godot uses something called nodes which is similar to objects if you're familiar with unity or unreal I think they're also called objects in game maker but basically anything you're going to interact with in the game is going to be a node or it's going to be affected by nodes so over here in the scene hierarchy you can click this plus button or you can right click and click Add child node and we're just gonna add a normal blank node right here create and go ahead and click that until you can rename it and we're going to call it world I'm using a capital W you don't have to do that but it's good practice for this and go ahead and hit ctrl s to save it's gonna say save this as world TSC n so that's your world scene that's what we want to do so the first node you put in to Godot is automatically like the defaults name for whatever senior in this is like the master node for lack of a better term ok now that we've done that we're gonna create a player our player is going to be a physics body so that that means he can interact with physics in the space so to do that you can right click this world node and click Add child node and since we know it's a physics body of some kind you can start typing that in and see what pops up pH y as okay so right now we have a lot of different physics things these things here in red those are for 3d games and you can tell the difference because the 2d stuff is blue it also says 2d at the end of it we're gonna use a kinematic body 2d which if you think of like kinetic energy like has to do with motion so kinematic means that you can basically the user can move it around with input and you'll see right here there's this little running character there that lets you know hey this might be good for characters go ahead and click create on that and then we'll right click on this kinematic body that we just put in add another child node and we're looking for sprites so you can start typing SPR there's my sprite right there and a sprite is just an image in a game it's just a 2d image yeah yeah it's just a blank node so when you click this plus button up here it's up at the very very top just as a node so a sprite is just a 2d image for your game and it'll represent characters backgrounds all kinds of stuff and right now our sprite isn't showing anything see it looks like it's about one pixel wide if i zoom way way in here which is kind of confusing little pro tip if you hold down the spacebar you can click and drag the whole scene view you can also do that by clicking and moving your middle button if you have one so whether sprite selected the Godot icon is always available as a texture in Godot games which is nice if you need a placeholder which is exactly what we're going to do you just grab this icon and drag it over here to texture which is under sprite and you can see this little blue box highlights to let you know you can drop that right here so now we have our little Godot robot right there and let's see did we do anything else with him yet not yet one thing to note so I've got my sprite here and then if I click the kinematic body you'll see that they are in the same place the same square you might think if I click in the middle here and I drag him over I'm dragging both the body and the sprite but you're actually not doing that that kinematic body is still over here and if I move it the sprite is gonna move relative to that we don't want that to happen so I'm gonna hit ctrl Z to undo the things I just did and with your kinematic body 2d selected you want to click this little button that's right next to this lock icon and if you hover over it it says make sure the objects children are not selectable so all that means is if I click on this I'm going to click the parent object which is this kinematic body and the sprite will move with it all right now that we've done that we're gonna turn on the grid and we're going to turn on snapping because a grid will let us know that we're putting things exactly we want them in the game world and snapping just keeps things nice and orderly so go ahead and click this little button right here this little magnet with the four dots not active it activates snapping and you can click these three dots right next to it and we're going to configure snap like that we're gonna change grid step from 10 pixels by 10 pixels to 32 pixels by 32 pixels make sure you delete what was there before or you'll be like making it three thousand two hundred and ten pixels okay and then once you've done that click this view button right here just as view show grid now we have this nice handy grid and he always snaps exactly see the grid so go ahead and put him just somewhere in the middle of your blue rectangle play space right there okay is there anyone who needs to catch up or his getting lost okay so we're gonna add our first script to the game so we're gonna do some coding now so select your kinematic body 2d and you can click this little scroll with a plus button right here to add a script or you can right-click the kinematic body and click attach script we're gonna be writing this in GD script it inherits the kinematic body 2d and all that means is that this script will be able to use all the functions and methods and special variables for kinematic bodies but that makes no sense to you don't worry about it so you don't have to change anything just hit create ok so this is the built-in script editor in Godot which is really nice in my opinion you can use third-party coding editors I don't see a lot of reason to do that unless you're an advanced user so we think we had two people here who are brand new to coding is that right okay so python works a little bit differently from things like JavaScript or C sharp it's all based on the indentation of your code and right here when you see this little hash sign you are creating a comment and all that means is that when the computer reads this code and spits it out into your game it's going to ignore any line that has this hash symbol so it's a good way to leave yourself notes or to describe what your code does or if someone else is going to be looking at your code later it's a good way of explaining to them how it works so for example just here at the top I could put a hash tag around hash sign and say like this script controls movement and everything else we have in here we're actually going to get rid of so everything under that note I just wrote just highlight it backspace make sure you keep this extends kinematic body TD you do need that so let's see we're gonna set up the physics process because this is a physics object so we need a function that's going to interact with the physics in this game so you're going to type the keyword func F UNC just short for function and then what I say it's called the physics process so I'll just I'll just start typing pH Y and there it is it's already showing up in the autocomplete so this is a built in function so it finds it automatically so I can just press enter it'll type the rest of it out for me and make sure this little colon is right there that's important when I press ENTER you'll notice that my cursor has been indented it's been tabbed in once so everything that's on the same line is part of this physics process function so just to give you an example I could write like you know some code some more code even more code and they're all in that same indented line that means they're all part of this physics process if I were to press enter and backspace to remove that tab now I'm in a place where I'm writing a totally new function so if you have any issues it should actually give you an error if you try to run code that's proper improperly indented but if you're used to things like c-sharp or JavaScript it's actually a lot easier like I not even sure if I remember enough JavaScript but you know you might see something like define some function with parentheses and you'd have an open curly bracket and then you'd have you know some code and then you have to close the curly bracket you have to make sure that all of your lines have semicolons at the end you don't have to do any of that stuff we have GD script it's very similar to Python but you can put semicolons at the end of the line if you want for some reason but you don't have to ok so what we need to do with this physics process this function runs 60 times a second so basically every frame of animation in your game this process is going to run so this function just monitors your game and what we're going to make it do is check to see if the user has pressed a button and that the user has to apply some motion to this character before we do that we're going to have to create a variable so above this physics process I'm just going to make some room right here and I'm going to create a motion variable and I'm going to do that by typing the keyword var var and we'll just call it motion we're going to set it by pressing the equals sign and then vector 2 with a capital v you'll see that it turned green because that's a special word in Godot then it open and closed parenthesis so if you know anything about python this is different in python you don't have to declare variables I could have just written you know motion equals your variable or something like that but in Gd script you have to have that VAR keyword so this is a vector if you're not familiar is basically just a direction it's just a direction and a velocity so we're going to be changing the x and y values of a character using that vector so in your physics process right here remember make sure that your intended that one one tab we're gonna say if capital I input and you'll notice there it is in the autocomplete if I want to find it that way dot is underscore action right here I'm seeing a couple of different options is action just pressed is action pressed is action just released we want is action pressed and you need an open quotation mark it can be a single or double doesn't matter and we're going to select UI right so this is a default button in Godot and UI right is just set to the right arrow key on your keyboard you can actually change that mapping in the project settings but we're going to keep it at the default right now and once you've got all this typed up make sure you put in the colon at the end because that tells Godot that this is a new if statement and when I press ENTER you'll notice that it tabbed in one more time so everything under here is part of this if statement so if input is action pressed UI right if the right arrow key is pressed we want to change our motion so we're gonna say motion dot x equals 100 so all we're saying here is if you press right on the keyboard the X value of our character should increase by 100 pixels per second to the right it's just like math class X increases to the right decreases to the left and actually that should await we have to do one more thing is we need to we already saved our scene so right up here there's this play button go ahead and click that and it's gonna ask you it's gonna say no main scene has ever been defined select one yeah let's do that select and go ahead and pick your world ts CN basically Kudo is just saying that you have to have a main scene what's the first scene that it should run when you start your game and look we have a video game sort of it opened it has graphics it didn't crash that's a good start but when you press write nothing actually happens there's a reason for that go ahead and close that window and so that we told it to change this variable but we never actually told it to apply any motion to this physics object and Godot actually has a function built-in for that and let's see if we can find it we're gonna use the help Docs to do that so you can click search help right here that's one way to do it and I could start typing in let's see well this is a kinematic body 2d so maybe I should learn more about it like that another way you can access the help is just by holding the control key on your keyboard and then highlighting any word in your code and clicking on it so I'm gonna click this kinematic body 2d so here's the help Docs right inside Godot super handy you don't you have to open a browser you don't have to be connected to the Internet so one of the reasons I like this program let's take a look at some of the functions that are available here let's see get slide collision is on floor move and collide move and slide that sounds kind of like what we want right because we want the character to be able to move so let's click that and right here it says moves the body along a vector now if you remember that motion variable we set up is a vector so this is exactly what we want if the body collides with another it will slide along rather than stop immediately which basically means if our character were to say like jump and hit a wall he's not just gonna get stuck in it he'll slide down so back here in our script underneath this if statement but make sure you're not indented and actually part of that if statement just type move underscore and there's that move end slide right there so move and slide and we're gonna put our movement vector in there motion move in slight motion and now hit that play button hey he moves but he never stops and I can't make him go left so that's the next thing we're gonna do okay so under this if statement go ahead and press ENTER a couple times get rid of that tab so if we made a move to the right by changing the X by 100 can anyone guess how we make a move left anybody that's right it's exactly right so I was that was a good guess so if input capital i dot is action pressed and this time we're going to say you I left close parentheses : press Enter motion x equals negative 100 and press that beautiful play button all right class over congratulations you're a game developer now but he doesn't actually stop you can make him go left and right but he's always kind of moving and you know what maybe you find out that would be a fun game mechanic but we're not going to do that tonight so now we need we're checking to see if we're pressing to the right we're checking to see if the player is pressing left now we need to check to see if neither one of those things is being pressed so we're going to use a new statement instead of if we're the second if statement is we're going to change it to L if e li F that's just stands for else if so if I press to the right do this else if otherwise if I press left I want you to do this and then finally we're gonna do a third statement else : that's just saying if any of the other things aren't happening do something different I'm gonna say motion x equals zero my mouse keeps sliding down the screen because it's actually sliding down the podium when I'm talking that's it's like it's alive okay so we have this else : motion x equals zero if I'm pressing right move 100 pixels to the right else if I'm pressing left move to the left else if neither of those things happen make it stop so press play now I guess I should close steam gonna be good okay left left right oh man he moves two directions he stops when they're not pressing anything we are making really good process a process progress all right so now that we've done all that we're going to create something for our character to actually move around on so we have a character but we need something for him to walk around on so click your world node here right click say add child node and we're looking for another physics body so start typing PHY and down here there's that kinematic body we had before but our walls are never really gonna move we're not going to make them move unless maybe you were to make moving platforms but tonight we're gonna have static walls and here's static body 2d and just like kinematic body 2d has this little running character static body has what looks like a little wall or a platform because that's what it's good for so go ahead and create that and you'll notice it pops it right up here to the origin just like it did when we made our kinematic body and right click your static body 2d and add a child node we're gonna add another sprite I could start typing sprite again to find it but it's also over here in the recent nodes that I've added so anything you've added in your game is going to show up over here and it could save you a little time so now with this new sprite selected once again I'm gonna drag this same icon over into the texture area and just like before I'm going to select our static body and press this button next to the lock icon and you might be wondering okay this is gonna get confusing pretty quick because we have a character and a wall they look exactly the same we're gonna cheat because it's easier than creating wall texture I'm gonna click this new sprite that we just put down and down here in this area which is called the inspector if you scroll down to where it says visibility and then it says modulate and click this little white square and you're gonna click into this color selector and drag down and to the left and now we have this lovely black box all right is everyone caught up I hope ok so now we've done that but our character can only move left and right there's no gravity so we have to implement some gravity so we're gonna go back to our script actually before we do that so we don't get too confused like this kinematic body 2d static body 2d it takes a long time to say it doesn't really say what it is so let's rename these things so static body 2d here we'll just rename that to wall and our kinematic body rename that to player all right now with the player highlighted I can just click this little script icon it'll take me right back to our script and okay so when you think about it what is gravity gravity is just it's just a force that's pulling down on us at all times and it's really depressing when you think about it but we're gonna do the same thing and just like the X and y is your left and right values the y-axis are your up and down values now in most programming and in most game engines there's a little difference between what you learned in math class and that is that for Y to increase it's actually going down on the axis so in your math class you move up that means Y is increasing it's the opposite for games if you want to get into the why of it it's because this the upper left corner of your computer screen is considered zero zero so moving down from there is increasing because you can't move up from there okay I got real nerdy and I'm sorry alright so in the top of your physics process Delta we're going to press ENTER to move this UI right if statement down one and we're going to put something new here so if I want gravity to be pulling down on this character what is happening to his Y motion can anyone guess that's right good job Daniel so it so right here at the very top of a physics process you're going to just hit in motion dot Y so the Y value of our motion vector plus equals 10 if you haven't seen this plus equals before all that means is this line here says increase the Y value by 10 and remember this physics process runs 60 times a second so 60 times a second the downward pole is increasing by 10 and that's actually gonna create a problem later which will we'll get to but even just with that if you press play see what happens okay fell down but he fell right through the wall not what we want all right let's see if we can figure out why okay well you'll notice right here Godot has already been trying to tell us that we're doing something wrong if you look at your player or the wall there's a little warning right here so if you hover over that what does it say node configuration warning this node has no children shaped so it can't interact with this space consider adding collision shaped 2d or collision polygon 2d children nodes to define its shape so what it's saying is that as far as Godot knows it has no idea what shape these images are so it doesn't know how they should interact with each other physically so we're gonna add a child node to our wall do that first so right-click your wall add child node and what did it call it a collision shape so I'll just start typing co ll I okay well there's a collision shape but those are the red ones those are for 3d so scroll down here there it is collision shaped 2d will create that and you notice it puts this tiny little square inside of that one but if you look over here in the hierarchy it's giving us another warning what does it say node configuration warning a shape must be provided for collision shape 2d to function please create a shape resource for it okay so I've got this collision shape selected let's take a look at the inspector down here and oh right there shape and right now it's set to null which encoding basically means nonexistent so if I click that and I look for this right here new rectangle-shaped 2d I'm gonna zoom in on this so you can see it so this is where this box will collide with things and obviously it's not the right size it should be stretched out to the edges right so you're gonna grab these handles on the inside and stretch it out like that until it covers all four corners make sure that you do not grab these outside handles because that's just changing the scale of this and it will actually screw up your collisions like manually yes like like right here and I think I can't do it my transform I'm sure there is a way to do it manually yeah you could change you can change the extents but now they'd be confused everyone grab these inside handles and just stretch them out to the size of your box they're gonna zoom out and we're gonna do the same thing for our player here so click player right-click add child node find that collision shape 2d or remember it's over here and your recent stuff too and do exactly the same thing it's kind of hard to see because they're both blue but I know where the handles go oh I got I have to give it a shape forgot so down here in the inspector new rectangle shape 2d stretch it out using those inside handles okay everyone with me you got it all right click Play Oh monkeys yay but watch what happens when I fall off well he falls really really fast like super fast we're gonna get to that in a minute for now just just keep it in mind okay so now we have the two basic components of any game right we have some structures for a character to move around on and we have a character on which to move them so we'll take this wall here and you can just click the wall and hit control D for duplicate and you'll notice over here the inspector now it says there's a wall and a wall too so if I click this wall and drag you'll see I've actually created another wall I can do the same thing again control D make another wall control D make another wall control D to make another one maybe this one I'll just stretch it out this might mess with our collisions I don't actually know control D and I would say make at least one side of your level have some height to it because we want our character to jump up there later okay once you've made a couple walls you'll notice that your scene hierarchy is getting kind of messy because you have all these walls in there and we don't like that so why don't you collapse all the walls that you have here looks like I've got five of them and if you click your world node here and you right-click and add child node we're just gonna add another regular node and if any of you have used unity this is a trick that you use in unity a lot you're just creating an empty node and we're gonna rename it walls and then I can select this wall hold down shift to select my last one I can drag all of my walls into this node and then if I collapse that node I know all my walls are in here but it's not making my workspace really messy and now just for fun I'm gonna test it one more time all right he's moving kind of slow we'll probably want to change that later and then it did that super turbo fall again okay so now obviously we need to get him in the air we need to allow him to jump so in order for him to jump we need to find somebody to detect if he's actually on the ground because if you don't he can just jump in midair forever which maybe you want to do that for your game it works for Kirby but for tonight we're gonna try to figure out okay how do we know if he's actually on the floor so that he's allowed to jump so let's go back into our script which you can click the script tab up here or you can click the little script icon next to the player and you know what let's go back into our help Docs because I bet maybe there's something in there so let's search for help and kinematic right there kinematic body 2d and let's in fact I think I remember something so is on ceiling is on floor that's a boolean value which means it's true or false let's click on is on floor and see what it says returns true if the body is on the floor that's exactly what we want and it only updates when you're calling the move and slide function so that's perfect I think we'll use that so you go back to your script which you'll see right here this kinematic body 2d GD and underneath this last else else statement press ENTER a couple times make sure you remove that tab and so it was what is on floor right so if is underscore on and there it is is on floor I'll just type the whole thing out for fun his on floor open and close parentheses make sure you add a colon so it knows this is a new if statement press Enter will do another if statement if capital i input dot is action just pressed so this is different than is action pressed his action pressed is just detecting whether or not the key is currently down and currently being pressed his action just pressed is listening to see was it pressed at all and it's going to wait until it's pressed again before it gets triggered so for jumping that's what we want so if input is action just pressed we'll open up our quote and say you i up so just the up arrow key close the parentheses put a colon press enter and so if gravity pulling us down is adding to the y-value how are we gonna make him jump anybody that's right so we're Justin oops motion dot y equals negative 400 so his upward motion will take him up at negative 400 pixels per second but just remember that gravity is always pulling him down at what 60 pixels per second so he'll go up but then I'll have to come back down so go ahead and hit play let's see what happens okay nothing he doesn't actually jump why is that well let's see I bet it has something to do with that is on floor so let's close this and if we look at our help dock which should still be open for kinematic body to D so is on floor remember it says it returns true if it's on the floor only updates when calling move and slide so let's check move and slide again see what it has to say and right here for the move and slide function you'll see some different parameters that can go into it well here's one right here called floor normal and it's a vector two so that basically means it's a direction and right here it says floor normal is the up direction used to determine what is a wall and what is a floor and it defaults to zero which is good if you're making a top-down game like Zelda our Pokemon because everything you run into is going to be a wall of some kind there is no floor for you to jump off of because the whole world is a floor so if you're making a side-scrolling game you basically Godot doesn't know which way is up you have to tell it which way is up so if we go back into our script and we're going to create a constant value which is like a variable but it never changes and usually you declare your constants before everything else so put it above this motion variable and you need the keyword Const which is Co NS t and usually when you're naming a constant you make them all uppercase letters so constant up uppercase u uppercase P equals vector two again with a capital v and open that parenthesis and 0 for the x value negative 1 for the Y value so basically that's saying like there is no direction to X on either side but you have negative one direction for Y which is that way so that is what the game now thinks is up so now in our move and slide function down here after motion we're going to put comma and then up again make sure it's all uppercase and once you've done that hit play I know why I like that Bob Dylan is playing right now I don't think he would approve that videogames so he can jump now is everyone jumping I hope now but what's this weird problem let's see if I stay up here for a little while and I move off to the left what falls off really fast but if I jump off pretty quick he doesn't fall sit fast I sit here I sit here sit here and I move off whoo okay so the reason that's happening is remember we're adding 10 to the Y motion 60 times a second so even when I'm standing on the ground his Y motion is increasing forever and ever and ever and ever and ever so when I walk off of that platform if I've been standing on it for like three seconds gravity is now what like 180 and it's kind of ZAP me down really fast and this is the most programmer e part of the evening this is one of the hardest things to explain why this makes sense but we're going to take a look at this moving slide function again in our documentation so if you look at that kinematic body 2d you scroll all the way down to the bottom right here it says it returns the movement that remained when the body stopped so basically means this function tells Godot or any any thing that calls it like how much movement was left whenever it stops which should be 0 right if it hits the ground it should be at 0 if it runs into a wall it's X speed should be 0 so we have to use that return value and if you don't understand why this works I don't blame you I don't fully understand it myself but by our moving slide function right here all around the left we're going to say motion equals move n slide motion up so at the very end of this physics process our motion will be set equal to whatever this function returns which should be 0 if it's on the ground it's not going to change unless it's falling and if you press play you'll notice that sure enough I fall very gently now no matter how long I stay up here okay so that's all the basic instruction for tonight but now that we've written all this code and we have a functional platformer in let me remind you looks like 21 lines of code so far you're gonna want to go back in here and change the game like for instance he's moving really slowly right it doesn't feel right it doesn't feel good so if I've just brand new to programming I might say okay well this motion x equals 100 that's too slow I want it to be twice as fast I'm gonna be 200 and then I hit play and the first thing that happens is it starts up and I moved to the right oh that feels a lot better he moves a lot faster but I move to the left and oh it's still really slow that feels good that does oh wait a minute that's right I have to change this value right here to negative 200 so we're gonna use variables to make this a lot faster variables basically let you change your code in one place instead of having to change it in a bunch of different places it saves you a lot of time and a lot of headaches so we're gonna create some new variables let's see this motion dot X is how fast he's moving right so it sounds like speed probably so variable speed equals we said what 200 feels good what other things Oh how strong do we want the gravity I don't wanna have to come into this code and change this ten every time so I'll create a variable for gravity we'll keep it at 10 for now and we also have this right here this negative 400 which is like the force of his jump so I might say the variable jump underscore or force this is the convention that Godot prefers but you could also say like jump and that a capital F for force either way works it's just good to in your code let people know where there's a break between words if you're using more than one word for a variable it's almost a variable jump underscore force equals negative 400 that seems fine and now here in the code instead of using these numbers these hard-coded numbers what's up oh but well yeah and in some ways it might but for now we're in it we're gonna do it this way for now though I'll explain why in a minute so now that you have these variables set up you want to get rid of these hard coded numbers hard-coded numbers is like a dirty phrase and programming like you don't want to do that so for this motion dot y plus equals 10 we're going to say motion dot y plus equals gravity and motion dot x equals speed and for moving left motion dot x equals negative speed and for our jump code instead of negative 400 will say motion dot y equals jump for us by the way the autocomplete also works on variables that you've defined so when you start typing it out it will finish it for you and I don't have to put a negative jump force because it's already negative where I declared the variable all right so let's see we set the speed to 200 what do you want to change should the jump go higher should gravity be stronger anybody stronger gravity lighter gravity I will probably fly off the screen and see what happens okay so I just said gravity there's no jumping why honey jump now okay I did something wrong jump force equals what did you misspell it I'm not sure why he's not jumping it is on Florida let's try that again I wonder if the gravity is so light that first oh yeah so I didn't think I was on the floor yet it's probably like a sub-pixel problem yeah so yeah that's too light well we'll increase that to uh that's 240 let's let's so we've just increased gravity by 4 times what it was before so I can barely jump at all this actually feels a little bit better than a big floaty jump if I'm being honest but still even doing that if I want to change stuff I still have to go into my script I have to change the numbers manually and maybe I want it to be faster or maybe I'm working with a designer who's not comfortable looking at code and so I want them to be able to change stuff in the editor itself so Godot like a lot of other editors has some pretty handy functionality for that so next to each one of these variables we just set next to this VAR speed equals 200 we're gonna say export and put a space you notice that turns red and export gravity export jump force and now if I go back to the editor view see where it says 2d here oops if I select my player now if you look in the inspector here they are there's speed gravity and jump force and remember that jump force in the code is jump underscore force Godot is smart enough to know that that's two different words so it separates it for me export yeah Daniel's really curious about them so that means that you know like so Daniel is a game designer and he you know he comes up with concepts but maybe he's not writing all this code but he's gonna be the one deciding like what feels good in the game and so the coder the programmer can set this stuff up for him so he can make those changes on the fly to see what feels good so if let's see that gravity was pretty strong maybe I will increase the jumps B or the jump for us to like 600 I can also just put in a number negative 1000 let's play so there you go now you have a functional platformer that we made in gosh boy like about an hour pretty much and it has all the functionality you need to get started you're going to want to create some actual graphics for it you maybe want to set some goals for your levels so that it moves on to other levels and just because Blixen mentioned it I think I am going to turn these two constants I think I can still do that it should still work you get read suppose Pig no it doesn't like that I think there might be another export function that will let that work but I don't know what it is oh wait wait wait maybe Const and I might have to define well I'm not sure you're not gonna worry about that but so what is the next step now that you have all of these little pieces if you're trying to learn how to yeah well that would be the next step but but no I will say that Godot does support exporting to Windows Mac Linux iOS and I think Android as well is that is that implemented is that like coming up do you remember and I think also WebGL as well so you could upload it to be played in someone else's browser so all that functionalities there I know that at least one Godot game has been ported to ps4 I think it was Deponia what's the name of the game but that requires a lot more effort but some of the other things if you're new to making games some of the other things you might think of are like okay so I've got this stuff but let's take a look at this game right for example like there's no camera to speak of right it's just static it never moves so your next step might be okay how do i implement a camera and i actually went through this process the other day i'm going to tell you like 90% of all development whether it's web development game developer whatever is whatever problem you have and just like googling it until you figure out how to do it so i mean i could just say ghetto camera follow you can see I already googled it once and we've got some YouTube videos that kind of explain how to do it we've got a QA on the Godot forum let's take a look at that one and this is all theater because I've read this before but we have someone asking how do I manipulate this camera and right down here this guy says in the editor creating camera to denote as a child of the character on the camera properties select current that's it that's literally all you have to do so if I right click this player I have a child node I search for camera camera 2d ok now that I have this camera selected you know current ok there we go like if this is true the camera is the active camera for the current scene only one camera can be current so I can just click it right here in the editor I don't have to do any coding at all you know so now I have this blue box around my scene what happens if I hit play check it out I have a camera that follows my player not only that by default it actually has an offset it doesn't actually just follow me pixel by pixel if I get in the center of the screen it waits until I hit a certain threshold before it starts to follow me again which is pretty common in most games and like implementing something like that in like unity or unreal would take longer it would require some coding at least as far as I know and we did that just now and I'm like two seconds and now that we've done that I can show you so I followed a series of tutorials by a guy named heart beast who's been doing a lot of game tutorials for a long time let's see if I can actually find this series I was looking at yeah so this platformer game tutorial series he's got seven parts right now there's more on the way but these videos are anywhere from like 20 to 30 minutes some of them are shorter everything I've shown you so far and everything I'm about to show you I managed to figure out in two or three days so just for example here this is still open if I open Godot here and I hit Project to go back to the project list yes and okay so using that tutorial series I'll just I'll just show you what all is in there so just a couple hours over a few days I have a start menu with functioning buttons that was on purpose did not draw this art not mine totally open source yeah it does very easily yeah so I'll show you some of that too so this is a tile map that that's created this this ground that I'm standing on you'll notice the the background is parallax it's moving at a different rate than my character obviously we support animated sprites you know I have a little this jump is so hard yeah I've got a little gait that takes me to the next level which this one just takes me right back to the first level but so there's a lot going on here and this is all running on basically the same code that we made tonight there's some extra stuff in it it's harder for you to see it then it is for me to feel it but there's a little bit of friction involved you notice he slides just a little bit he also takes you know just a slight amount of time to actually accelerate to top speed so it feels a little bit more like say like Mario or something like that and you'll see yeah you can see him sliding back and forth when I turn around after he's at top speed so those are just little things you can add without too much more code that make it feel a lot better to play and then I'll show you something Charles was just talking about if I go into let's see my first world scene here this is actually kind of tricky to get it running but when you do if I select this here my tile map check this out I can put my tiles down wherever I want and it automatically knows how to stitch them together properly the alternative to this is to you can do this in Godot too is to have a tile map which is just a series of you know 32 by 32 squares and you can select the ones you want and paint them on select the next one that connects and paint those on or if you go through the trouble you can actually set up an auto tiling system like this it takes a little while it's not basically what you have to do is you have to have the artwork and there's there is a method to creating the proper number of tiles depending on how big they are and then once you've done that you define what's called the bit mask which is telling the game how they stick together and then for each individual tile as far as I know there's no way to do it on mass you have to define the collision for the tile so so that the game knows that you're not just going to fall through it yeah the notes because each one of these tiles has like basically essentially one of those collision bodies mapped to it by default so anything that I just put down right now I didn't do anything extra to it oh it already works I don't have to do anything extra and you know if you get to that level and you start making different tile Maps maybe you make some that are for background elements that go behind the character or maybe you make foreground decoration tiles and things like that so it's it's for a can entirely free program that you never have to pay for ever even if you make ten million dollars it's pretty darn powerful and I've been I've just been really really happy with it and like I said everything that you're seeing here I I did following some tutorials in a couple of days I have not messed around with the 3d functionality at all I mean like if you go to their home page I mean you can see that it's it's certainly capable I didn't do what I did do some the actual tile mapping didn't involve a script it just involves you have to let's see if I have the asset here somewhere okay so this is actually this is another technically it's another scene and this is a weird thing that Godot can actually do my mom my player who is in this scene right here the player is himself a scene you can actually save a scene and instance it inside of another scene which is a good way to kind of commit compartmentalize the work that you're doing so like if you have an artist who's just working on certain art assets they can have it on their own scene without potentially messing up something that you're doing kinda yeah so it's it's very confusing because you have nodes inside of nodes and then you have scenes inside of scenes and it gets weird but like an example I saw in an article was like let's say you have a wall with a lot of pipes coming out of it and going back in that like in unity you just have to put all those pipe objects in there and fit them properly but in Godot you could just make individual scenes for different sections of the pipe and and it's it's really powerful but also very confusing to explain but like so this is actually the tile map that was used for this and let me see so which what I'm trying to remember is there's a there's a section where you actually have to define what they call the bit mask and you have to define all of the collisions and all that I just don't remember yes it is and even he is so Auto tiling his new ticket oh it was new and Godot 3.0 and even he's like it took me a while to figure out how to do this it's like I don't really fully get it yet and I don't think it's even probably fully implemented yet the way they want to because I'm sure they're probably going to want to make it easier because if you look at these individual tiles like I mean that that's like one tile actually I think yeah so like this is one tile and I had to go in here individually and say okay set the collision for this tile except the collision for this one set the collision for that one and that's yeah in fact I think I think the tiles might be two by two let me see I actually just in the well in the the Tulsa game devs Facebook group I put a like an overview of making tile maps and they showed like here's a basic these are the different kinds of tiles you'll have to make if you want to make a whole set that will connect to each other so it literally said just take this and put it into your image editor of choice and just draw whatever you want on top of it and make sure it's the same shape and it'll work but that's that's it I mean that's that's Godot like I said I haven't really messed with the 3d at all one thing I will say is that there are sample projects you can download you'll have to go through like downloading a repo on github and if you've never done that before that can be kind of daunting
Info
Channel: Tulsa Game Developers
Views: 509,978
Rating: undefined out of 5
Keywords: godot, godot engine, game dev, game development, tulsa game devs, tulsa game developers
Id: xQIaRSXh4ic
Channel Id: undefined
Length: 61min 57sec (3717 seconds)
Published: Fri Apr 20 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.