How to Create an RPG in Godot 4 (step by step)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to the most important and informative Godot 4 tutorial series you'll ever watch because we're going to be creating this game you see on screen from start to finish step by step and I'm going to be explaining how everything works and why everything works we will be starting from creating our player to movement to AI enemy to our own combat system to changing scenes having a weather cycle to having smooth camera movement using tile sets Etc we will be going over everything you need to know about go to Ford and how to create your own game as I said this exact game is the result of this tutorial Series so you know if you want to create an RPG this is the perfect series for you but let's get started with episode one and before we get started I just want to ask if you could go down there hit that subscribe button drop a like on this video to help you to push this series to more inspiring game developers so that you can learn to make their own good at games as well but without further Ado let's hop in and get started with episode one of this series so in this episode we're going to basically keep it simple create player movement and create like a grid type of player movement so it goes up down left or right and we're gonna have like a semi-advance animation system thing so we'll have like a bunch of different animations playing based on like what state the player is in right just like well let's just create it right so so I left a link in the description to this art folder right here and you can see we have you know a couple characters which is our player and a salon we have some objects and we have our grass and planes tile set so you can download that on hio I will have a link to it in the description I'll make sure that I give you know credit to the owner and everything because it is not my art but I'll make sure credit is given and yeah go so go download this in the hio if you want to copy everything exactly exactly but if you already have like your own art then you should be fine so I also want to go down here just so we can keep our game organized and we're going to create two new folders we're going to create a folder for our Scripts and we're also going to create a new folder for our scenes right and then I'm also going to drag this icon which comes in the game into our art folder just so it can be in there so everything looks organized and now we have you know scenes in a script folder so we're going to start off by making a brand new scene which is going to be a 2d scene and we'll just name this uh world and if we control s we'll save it and we'll make sure we save it into our scenes folder and now we have you know something in our scenes folder which is our world but we're not really going to do anything to the world to be honest in this episode so we're going to go and create a brand new scene and we're gonna make a other node and we're going to use a character body 2D so in the old Godot this used to be called a kinematic body 2D but now it's called a character body 2D it's basically the exact same thing and we'll just rename this to our player and yeah so we need obviously for a player we're going to need a collision shape 2D we're also going to need a animated Sprite 2D and for our animated Sprite 2D we're going to create our animations and that's what we're going to do right now right so we can go up here to our animations we can create new Sprite frame we click on this new Sprite frame and it will bring up this animation player so this is our yeah Sprite frame our animation and this is where we can create our animations right so we'll just name our first animation Idol and we can go up here to this grid go to Art go to characters go to player.png and it's going to bring out this right so this tile set is actually a it's six horizontal right because it's one two three four five six that way and then it's like 10 vertical and as you can see it splits everything up perfect and these top ones are the idle make sure you click them all in order like this so this is our idle animation right so if we add six frames and we zoom in on our player you can see it's blurry but we'll fix that here in just a second but if you see if we click play you can see we have a little bit of a idol right it's it's an idle animation so it is a little bit blurry so to fix this this is new in the new God so in the Old Goat it used to use to go down here to Art characters and then player PNG and you go to import and then you do it in here it is no longer the case you have to go up to project project settings and then you got to go down here to the render Tab and then texture areas which is or it's like in under the rendering tab right so under the rendering then textures and then you can see down here that we have like linear and we have disabled and everything this doesn't matter but the default texture filter instead of it being linear you need it to be nearest so once it at near once it's at nearest and we close it you can see everything looks clear and we have a clear animation right and then we have a ton of different animations so we have like a front [Music] idle animation and if we go and check in our thing it's going to make us you know grid it again but you can see that our front idle animation would be what looks to be the one that we just did yeah we just did that so this is actually our side idle so this one right here is actually our sod idle animation this one right here is actually our front idle animation but then we can create a new animation and this is going to be our back idle animation and our back idle animation is obviously going to be the very next row as you can see our characters facing back and this is our animation then we can create a new animation and this is going to be our walk animations right so we have our front walk and then we can go to our player.png and split it up right here this is our front walk because we're walking like downwards and then we have our sidewalk which is going to be right below those right so it's going to be these are sidewalking as we're walking to the side and the reason it's called sidewalk is because you don't need an animation for right and left because we'll just flip the uh character horizontally right but that's our sidewalk and then we also need our back walk and our back walk is going to be the very next one right here just like so and then we're going to have to have all of the different attacks right so we'll have a new animation and we'll name this r front attack and then we will split up this again and this is our front attack and then another animation which is going to be our side attack and our side attack is going to be the very next one and I know this is super super repetitive but we're about to get into the code and we're actually going to be coding stuff here in just a second and then we have our back attack back attack and then we go here we split it up and this is our back attack here and then we actually have a death animation right so we'll have a death animation and we can see that the death animation is the very final one like so if we actually play the death animation as you can see it looks like our player does die our back attack our front idle our our back idle our back walk our death our front attack our front idle our front walk our side attack front side idle and inside walk so that all looks good and now we have animations for our player okay so now that we have all of the animations for our player we can exit out of our animated Sprite we let's move this down right here and we need to create a player script so we actually have a script for our player and we'll just click this little button up here which is going to let us create a new script player.gd save and as you can see down here in our file system our player.gd came into a normal or it just came into the into the file system and it's not in its script folder so we can just move this into the script folder and everything is like looking organized and we also need to save the player scene so we'll save the player scene into the scenes folder and then that is all good so we're just going to remove all this in our character body 2D which is our player script and we're going to kind of make some variables for ourself which is going to be like speed and we'll set that to like 100 to start we can play around with it we can move the speed around here at the end of this video so we can like see what works best but we also need a uh oh I was about to make a emotion Vector but we no longer need motion vectors in uh Godot because in the old God you needed motion Vector right you needed to do bar motion equals a vector 2.0 right and then you'd call motion everywhere but now in go.4 it's velocity and you don't even have to create a variable so I'll show you what I'm talking about here in a second so let's start a a physics process function will pass for now and then let's create a new function which is going to like control all the player movement you know in our player so player movement and also pass through Delta here and in here this is where all of our you know players stuff is going to be happening right so we're going to get our input for if we go right left up down so it would say if input Dot or if input dot is action pressed not not just press but is action pressed and then is action UI right so if we click the right button then we're going to want our velocity if I can type we want our velocity.x to equal our speed and we want our velocity y to equal to zero right because this is like a grid based movement so we can only move up and then we can only move left and we can only move right and we can only move down we can't move in two directions at the exact same time but if you do want smooth movement I just created a video not that long ago on that I'll link it in the descriptions and it's like super smooth for you know super smooth movement but this is like a more of a grid based movement because it looks better for an RPG so we can just do is input dot is you know action press and actually I'm going to go right here and we can just copy this and then we can do else if and then paste that and then instead of it being the right we need it to be the left and then Varsity our velocity dot x equals speed it needs to equal negative speed so it can go in the opposite direction and then y still does need to equal to zero but if we copy this and paste it again then we have UI down instead of left and then velocity Dot y right velocity velocity dot y needs to equal to positive speed and velocity.x needs to equal to zero so we're only moving down we can't move any other direction when we move down and then uh velocity.x is equal to zero when it we're going up right and then the key is UI up so change the speed here to negative speed so we go up and then if nothing is being pressed right if no inputs being pressed then we want velocity dot x equals zero and we want velocity dot y to also equals zero because that means we are stopped and we're at a standstill but at the very bottom of the function we need to do if or we need to do move and slide and then just call that function it's a built-in go dot function and then this function up here we need to call into our physics process right the function that we just created so we'll do player movement and we'll pass through Delta we're not actually using Delta yet but we will use Delta here in a little bit so now that we have this we can play the player scene and we can see that we do have movement we can move down left up right right and we can't move in two directions at the exact same time which is good but you can see it is very very small so to fix this temporary fix we're gonna you know change this later in a different episode when we add our cameras and stuff but we can go to our project settings and we can go down here to window right here and then we can just scale and we can set scale to like uh we'll go with like four and then if we play you can see that it's a lot bigger and we can see the player a lot better but obviously it's not going to be scale four because we're going to fix that when we add cameras and stuff to the game and you can see player movement looks good but we have no animations so that's what we need to do right we need to fix the animations and to do that we'll go back to our player script and we need to make a brand new variable which this variable is going to be called our current direction so we'll just do current Dart equals none right because we're going to start off going no direction and then we need to go to our button right here right so we have Ur right so when we go right we need to set our current Direction equals to right so we know that we're going right and then we need to play our animation right so play animation one and this play animation right here is going to be our own function right but if we're going right we just we'll set our animation to one because that means it's like play or that means we need to be like playing a walk animation right so if it's one if we're passing one through our function that means we need to play Walk but okay I'll I'll show you guys this here in just a second but we need to start off by adding changing you know all the current directions so current direction equals to left and then down here current direction equals to down and then right here current direction equals to up and then we need to go create a brand new function and we'll name this function R play animation and then we'll just do like the pass through a variable and our variable that we passed through the variable that we passed through will be called like movement right or we can call it direction or anything no we'll name it movement because this means if we're walking or if we're idle right so we'll make two local variables what you're gonna only work inside this function for are yeah Direction variable which is going to just be equal to the current direction and then we're also going to have a variable for our animation player which is just going to get our our for our animated Sprite Which is just going to get our animated Sprite 2D and then let's create an IF function right so this is going to show like how we play our animations right because we don't want to be playing you know an idle animation in a walk animation at the same time we want to be playing them when they need to be played so we'll do like if direction is equal to right right so if the direction is equal to right then we'll do our animation which is basically our animation player dot flip H uh equals false because that means we don't need to flip it because we need to be facing you know we need to be facing this way right we need facing movement this way which is how our Sprite is set up and then we can do if our movement which is what we pass through the function the number that we pass to the function if our movement is equal to one then we can do animation dot play and then we can play our side walk animation right and then we do our else or else if movement is equal to zero which means we're not moving then animation.play and animation.play will play our side idle right so hopefully this makes a little bit of sense so let me let me make the function up here and we'll pass through so if we're going right then we want to call our animation right and we'll call the animation which is going to be play animation but then we need to pass through a function right or we need to pass through some number so we'll pass through one because that means we're moving right we're moving in some Direction right so then we'll go down here and we'll do play animation and it's kind of going to be the exact same thing so yeah it's going to be the exact same thing down here and down here we just need to make sure we call that function if we're moving any way and then down here is actually going to be a zero because this means we're not moving right because if it's else that means we're not moving velocity zero and everything is zero but as you can see if our direction is equal to right then it's going to make sure our animation is not flipped because if it if we're going left then this needs to be true right because we need to be we need to have our animation player flipped right so then it's going to say if movement is equal to one which means we're in a movement function which means we're in one of these but we obviously have to be in this one right because our direction is equal to right and if our direction is equal to right that's how it gets in here but if our direction is equal to right and we're not moving then we need to be playing the idle animation that's when we'll play PSI side idle right so that we can kind of just completely copy this and then paste it and then instead of it being right here we need this to be our left and animation flip needs to be equal to true and then these can kind of stay the exact same and then we can copy it two more times and for these two more times we can name this one R down and then we can name this our front walk and our front idle and then instead of it being left this needs to be up and this can be our back walk and our back idle right so now if we play We Should hopefully have animation if everything works as planned which normally things don't work as planned but as you can see walking walking idle side idle side idle up Auto down it all works right but if you notice at the very beginning when we play it has our player is frozen and that's because we did not add you know we don't have any ready functions so as soon as the game starts we don't have any function to tell us to you know get a animation going right so we'll do ready equals and then we'll just we'll just call something simple right so we'll just call animated Sprite dot play uh we'll do front idle right so front idle and that problem should not be fixed as you can see if we play it and we run around everything looks good and I think if we play it we should be moving yeah so we already have our idle and everything works so that is how you create a simple player we obviously we haven't done anything with the attack animations yet but that's going to be very soon when we create a combat system which is going to be pretty you know complicated pretty Advanced but it's also going to be very very cool so I hope this was you know an informative video and I hope this series is going to be a very very helpful series and it should be I know it will if you follow along and you will you will for sure for sure learn a lot but until next time hit that subscribe button drop a like on this video so others can learn to make their own good at games as well but stay safe and have a wonderful wonderful rest of your day [Laughter] [Music] thank you
Info
Channel: DevWorm
Views: 241,235
Rating: undefined out of 5
Keywords: how to make a rpg in godot 4, how to make an action rpg in godot, how to make my first game in godot 4, how to make player movement in godot 4, godot, godot 4, how to make combat in godot 4, how to make an rpg in godot 4, how to make game in godot 4, godot 4 how to make a game, step by step how to make a game in godot 4, godot 4 tutorial, godot 4 how to, godot 4 2d tutorial, godot 2d rpg how to, godot 4.0 how to make first game, how to make game in godot 4.0, godot engine
Id: pBoXqW4RykE
Channel Id: undefined
Length: 20min 57sec (1257 seconds)
Published: Mon Apr 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.