3D RPG Action Game Dev Tutorial in Godot 4.0 Course!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
with a giant number of courses out there there are so many different courses to choose from and you decided to look at this one now you're probably wondering what does this course have to do and what can I actually offer you that other courses don't well really hard to pinpoint the uniqueness of a course but my course is focusing on three things I can't promise you uniqueness however I can promise that you will exit this course going from I don't know anything about 3D to being a somewhat intermediate user for 3D and you'll be able to go on on your own and learn more about 3D stuff and create your own game hopefully now the three well four points that you're going to learn specifically in this course we're going to learn one about 3D World creation so we're gonna go over a bunch of different things like environments setting up different tile Maps Etc so we're going to go over the creation of a 3D world that you will be able to create the second thing that we're going to do is character creation with complex animation tree now characters can be created in so many different ways now one of the issues when it comes to 3D or any or 2D or 3D is animating now in 3D adding animation grows your options exponentially but it exponentially gets harder and I'm going to go over the very Basics just from animation player all the way into animation tree and we're also going to go into States and state machines now I'm going to go over the complete basics of everything and I hope that you will able to take everything that you learn and create your own character in the future the next part is dictionaries and an inventory system now creating an inventory system can be pretty complex in of itself however I'm going to simplify that with dictionaries so we're going to go over in-depth dictionary explanations and you're going to leave this course hopefully a master of dictionaries and not only will you be able to create another inventory system of your own but you'll be able to adapt your inventory system to however you like and the last thing it's not super complex but we're going to be creating a simple AI monster system you'll be able to create a world of various different monsters that you can choose from that you can add to the to your game or to any other game that you create so I hope you guys are ready for this course this course I hope you will have a lot of fun in and good luck okay welcome everyone this is going to be the first part to our Series so first up is we're going to go through the packs that we have and the options that we have so the first option is going to be the kkit pack so first off we have two sections to this game we have the Character Pack and we have the environment packs so for the characters I'm going to be going through two different ways of doing this we're going to go through the K kit animations going with the animations and the kkit skeletons I have made a video upon this before but we will include it in this series as well and the second option is going to be the meek Samo Character Pack so these guys this is also another site that allows you to have a lot of different character packs and we'll be going through the process of implementing this into the dough as well so that's two options that we have that we will be covering in this series so you'll have two options on that point and next up we have the simple grass texture this is just a very easy kind of plugin for Godot that allows us to as you can see add graphs so this is really cool you can download it down below and I'll kind of be showing that into our game later on next up is our environment pack so for environment packs we have a few options this K kit dungeon pack goes with the K kit animations and stuff but it's up to you really so another option for the environment pack is going to be these two the modular Village and modular terrain packs so these two kind of go together they're from the same artist these are actually kind of cool because um they have this artist has a way to kind of uh build this I think it's masked this guy so you can have you can implement this I think you have to buy it so it's not just for Unity I think it's a third-party software that you can build essentially to uh stuff like this outside of gudo and then re-import it into I'm not 100 sure we're not going to cover that we're just going to be doing most our work in Godot so it's just up to you and what you want to pick but this is a viable option next up is the actual item pack so this is going to be for inventory stuff so this is kind of important we're not going to use all of it but it's free and so you can download a few items from this or just download this pack and we'll be using it later on okay and lastly these the dev pack the dev assets pack so here we're actually only going to be using the fire starter guy and it sounds a bit silly but that's kind of mainly all we're going to use obviously there's more stuff so that you can use it if you'd like so there's weapons fences and you can just build whatever you like we'll be going through everything you need to know to set up everything together so the first thing we're going to do is make sure we actually export each folder that we need so here I have exported them already through each separate folder and I want you to make your own let's make our projects so I've already made it but I'm going to just show you how to actually do that in case you don't know so real quick we just open up Godot we go to new project as you already saw we're going to go to object path you can put it wherever you want I put on desktop you can click browse browse wherever you want create the folder and we're going to use forward plus you can always change this later but um we're going to use folder Plus for now and then I use none so that's what I did and then I created create and edit and let's open up my project so the first things we're going to do is I'm going to delete these so you're not confused so here we're going to go into a project setting we're going to change a few things well two things so the first thing that you're probably going to want to do is change texture here to protect your default to nearest we're not going to use linear we're going to use nearest and in case you don't see all these settings we're going to go to advanced settings on the top right next up we're going to go to window and go through a few different options so for the mode I'm going to be using windowed but you're more than welcome to use whatever else you want maximized full screen it doesn't matter now for the stretch we're going to be using canvas item the reason is because when I have something that I draw on the screen so if you're looking at my face and I drop Drew something on my face and I increased this entire screen I want this item to be expanded as well now if it's not canvas items that won't happen if we have it on disabled it won't work so that's why we need on camera's items okay so here as you can see I've already made a 3D scene we're going to save this and as world and we're going to run it and it'll prompt you to select current so we'll select current and run our first screen so this is just our 3D world there's nothing in it yet so we can't even notice that it's 3D and next up we're going to actually edit a few things in our animation pack so the first thing we have to realize is that there's a lot of different ways to have a 3D item so minimize these so the 3D items or 3D objects can be stored as different types of objects so here let's go into models go to characters and here we can see there's different types of things so we have object fbx and Dae here I'm going to delete these three and leave gltf I'm going to delete them because they're going to take up too much space I'm going to go to assets and same thing let's delete all three of those and let's go to Resource we don't need that let's delete these let's close this let's go to dungeon and we're going to have to do the same thing here so we're going to go to samples we don't need that let's delete all those and delete everything except for gltf let's go back here okay and last I up is the which one did I not edit I think it was the animation yeah awesome okay so here we go let's go to the animations we're going to delete the fbx we're going to go to documentation we don't need that we don't need the resources the model I don't believe we need but we're gonna play with it anyways we're going to delete everything except for the GLT I'm gonna delete all those whoops delete not enter all right awesome now we've deleted everything that we don't need let's import those into our game okay now that we've imported everything let's maximize our screen again and take a look at what we have so the first thing we're going to actually use is probably our character of skeletons pack so we're not going to make our character just yet but we're going to we're not going to animate it's just yet but we're going to make it so let's go to character body 3D and create it as a separate screen so here we'll rename it to flare and let's add a few things that we need so Collision shape we're going to create it as a sphere so here we'll make it as big as we want we'll move it up and lastly let's actually add our mesh so what is a mesh well that's a great question I'm glad you asked so let's open up our Character Pack we're not going to go to the assets because I think those are weapons and stuff so here we're going to use our base character where is it the minion that's the base one so here if we drag it out a little bit we can read it and say it says character skeleton minion I think broken is just the bones are broken that one has like a thing in his head yeah this one doesn't so we're going to drag this guy in and here we can see that we have our node 3D now we if we double click this guy this pops up and here we have a bunch of meshes so the mesh itself is simply the drawing essentially the skeleton so here we can look at each one separately and we have the eyes the head Etc we have so many things we have the hand and we'll close this and what we'll do is when we drag this in it ends up being a node 3D right so here's our node 3D what you can do is inherit this and say new inherited and this will pop up but we don't want this we don't want to save this and then reload it what we can do instead is is what is happening there we go oh that's really weird okay let's delete this and drag that back in okay that was a weird bug hopefully we edit that out uh okay so here what we'll do instead is we'll right click this and we'll go to make local now what we can do is take all these guys out or no actually we'll leave this in so now we have all the meshes and we just leave the node 3D to kind of contain all these meshes so now we have all the meshes as a local thing so now I can like make the head invisible for some reason or the eyes or the jaw I'm not sure why but you know we we now have that option right so now we've made everything local and now we have our player so let's actually make a new folder for our player we're going to have everything we put in our player there so let's save it let's go to our player make a new script we're going to use the template basic movement let's put it in and now let's add a camera 3D now for the camera 3D we're just going to place it above him for now just so we can kind of see the game so let's kind of rotate it so that it's looking at our player so here we have the red guy that rotates it right we have the blue one that will rotate it to the other way and that's it so here we can have the camera looking at the player so if I were to play nothing would happen because in our world we don't have our player yet now let's actually drag our player in so let's add this guy in and play and see what happens and most likely nothing will happen so we can see our player he's upside down so what we're going to do is we're going to go to our camera we most likely rotate it at the wrong way yeah so let's actually do that this way nope let's do like that there we go let's rotate this guy 180. the Y and then we'll just drag this down just a little bit there you go and now we have it rotated properly so that little triangle on the top means that it's pointing up so here in our world let's add a floor so that we can actually walk on something so it's not a collision but obviously we need a static body to hold that Collision so let's add a shape let's give it a box and let's just make it really wide wrong way there we go and let's drag this up a little bit and so here we should fall down well we should but we won't because actually we've already added our skip so let's see what happens let's see if we fall down okay here we go so here we can see that our player is in and if we try moving it seems like nothing is happening well that's because we have nothing as a reference so why don't we try adding a mesh to our our floor so let's make a mesh instance let's go here and we'll say mesh box and in our mesh box we'll just drag it using these guys or we can actually just use this and make it bigger so let's drag it out Make it try to fit it make it fit the floor of the actual Collision here we go and there we go there's our floor so now let's play and see what we got so now we can see our actual floor and we can see that it's moving or moving around now you might notice that the directions might not be working properly like if I go up I'm going back if I go down I'm going forward if I can try clicking to the right it's going to go to the left but that's okay we're not going to worry too much about this because we're going to be actually changing the player um controls and everything ourselves so but that's it for now so we now have a floor and player so that's good um one last thing we're going to do before I end this part is we're going to add the environment so what is an environment well that's a great question I'm so happy you asked an environment is something that will essentially allow us to change the environment around us and as you notice we added it and it changed so much already so let's let me just pull up my reference so I have the environment settings I made okay so the first thing I'm going to do is actually create an environment so we have to go here to the top and it's a new environment and we're going to go in here and we can now edit a bunch of things now here we have a lot of different options but we're not going to play with all of them however if you want certain effects like so for example glow or fog this is a great option because now we have fog glow there's so many different things you can do with environment now the main thing we're going to do to actually make this feel like a 3D action game is we want to go to background we're going to change it to Sky we're going to go to the actual sky this option should pop up we'll change we'll go to Sky and say new Sky we're going to go to the sky material we're going to make it a procedural Sky material there we go and now in here for the radiance size we'll do 128 and here I don't think I change anything oh no I lied I did do some things um here is where we can actually change the color of the sky so let's go to whoops let's go to top color and I used like a little bit of a more white because now it kind of feels like a white Sky you're more than welcome to do like a light blue maybe whatever you like and then for the Horizon color I use kind of a darkish blue not darkish blue but kind of blue wish so that's like the Horizon right so now we see the Horizon there and here you can change whatever you like you have the curb curve and change whatever you like so you can play around with things right so we have the energy multiplier cover you can play around with this but those are the settings I'm going to be using and no that's it action really that's it for the environment so we now have a sky with a uh Sun so what happened well here we can now see our shadow that's why we have a shadow because we've just added the environment so in our game you might not see it but that's okay we're going to be adding things in later that will actually allow us to do that so that's it for this part I'm going to be showing you guys how to import a character from mix Samo as well this is going to be another separate part so one of the things that we should keep in mind is here there's no animation player but we'll be using the kkit animation later on to set it up so you will have two different options to set up this character the cake hit or the mcsamo character now in this series I will most likely be using the K kit character for most of the stuff however just keep in mind you'll see later but once everything is set up it's basically the same so you don't have to worry about oh what if uh this it's a little different and I can't follow along don't worry it's going to be exactly exactly the same this character eventually will have an animation player here with like idle run and stuff like that and the mcsamil character will also have that so you'll see in a minute so let's get started let's first obviously um okay so the first thing I have to do is go to the main website you have to log in so make sure you're actually logged in because I don't think it'll let you download assets if unless you logged in so here let's go to the characters and pick a character so the character I would recommend picking is one with a prop so we have two options I'm gonna pick this one for uh so I don't get demonetized um and then we're gonna download it so we're gonna do FPS download boom boom boom awesome and now we're going to you can look through all the other characters and pick whatever you want now just keep in mind this one has a sword a built-in sword and that's kind of important because what's going to happen is if we try to pick one without a sword and attack for example it's not gonna really work properly so let's just keep that in mind whoops so we're gonna need idle let's look up idle so let's look for an idol animation that we want we can pick Maybe let's pick this one yeah um let's try to pick some things kind of short because the longer the loops on the bottom we can see here that this was 50 frames and the other one was 300 a longer frame is going to just be a little harder but it was obviously not the best 3D engine so we're gonna try to pick ones that are a little easier so that was an idle one let's find a walk animation see now okay here's the main issue when it comes to Godot so Godot has an issue when things walk forward like this so what we're going to do is we're going to make him in place so we're going to make him walk in place awesome so this is one option so let's download this fbx all the default settings walk now let's look for a attack whoops I guess they finished downloading attack so you can pick anything you want just keep in mind we have to try to look for one where he's in place okay these are all really weird attacks I think I'm gonna pick that one yeah let's pick this one let's download it and the last one we need is jump now there is two things to keep in mind so um this I think it's this one I think this is the one I used not 100 sure let's look through them together we can use this one yeah that one's the full one so you want to look for a full animation from start to finish so there's not going to be a falling animation that we're going to implement we're just gonna do the full jump let's pick this one one other thing to keep in mind in mixamo there is if I go here I can search up pack I think yeah and we have these packs so these packs are like magic one for example you can look for one that's for this character so I think if we scroll down here we go sword and shield pack now it's a little hard to download this pack and actually use it for a few different reasons one because you'll see later in blender it doesn't really work that well but two because some of them like walking they they're not in place and we can't change that so I would recommend just doing everything um separately and and just doing every every download that you need as a single file okay so now let's go to our game and let's import everything so first let's create a new folder so I don't get confused let's say mix ammo layer okay and now let's open up blender so let's look up blender and open it up and now here's the fun part so we have to basically import our fbx folders into blender and Export it again as a gltf now first of all as you can see I deleted everything in our scene so delete everything under scene collection now let's go to file import and we're going to import as an fbx let's find the files that we used so first we're going to import the Paladin with prop we're not going to import anything else just the prop guy just the actual t-pose so give it a second it'll load the character and you should be able to see our character as a t pose so here now what you can do is import the rest so now let's import the rest of the animations for idle jumping standing melee and walking and now it'll import all those and they'll be on the right side so the amateur we have amateur which is the t-pose and if we just give it a second load load load there we go that took a little second but now we can see we have a bunch of animations so now all we have to do is delete these guys we don't need them and I'll show you why in a second so now we have we're left with the amateur now let's go to the animation tab on the top that's now this was a bug and not a bug a little uh error I had when I was doing this my own sometimes the animations don't show up now the reason is because you haven't selected anything so make sure your character amateur is selected before looking at the animations and start panicking okay so now here on the left let's go to action editor let's now pick a different animation so this is the T post so we can actually rename this to T pose now let's take a look at one of the other ones and let's play it this one looks like the idle animation so let's rename it to idle and let's just do repeat that for all the rest of them so what is this one this one is jump so it's raining in that to jump this one should be walk let's rename that to walk and lastly this should just be attacked because that's the last one okay so now on our file now that we've renamed everything we want to export this file as a gltf okay so let's go to export and just do that so GLT up there it is and uh orig so now let's save it as a in our downloads file or wherever and we'll just name it as our character and now let's export you'll export and now we want to go to our project and simply import this guy so let me just open up my folder whoops so import the character that we just exported and let me find it there it is character.gbl glb it'll import it and hopefully my editor edits out me taking out my thing and everything that would be nice okay and so now when we open up this character we can see that this has popped up so let's take them our minion and hide it for a second now remember when we have a Gob rate kit an asset as a 3D all we have to do is just drag it in right so here we can see our character let's drag it up a little bit and reset its um transformation so let's do this so we can reset it in the middle and that's their character so he's actually the same size too which is quite nice or almost the same size and now remember all we have to do is make local okay now here's the best part this comes with the animation player so now we have animations for it we have attack we have idle we can play it we have idle there we go and now we can actually use this a little bit so here we have our camera and everything and it works quite nicely now what we can do so we have all these what we can do is let's go into our script and kind of play with this a little bit so I'm kind of assuming you know how to read code but we'll go through this anyways as together so in good dough or in 3D there are three axes we have x y and z now Y is the same as 2D so Y is the gravity Y is the the downward Force right so this is adding gravity to our character so if our character is not on the floor we'll try to pull them towards the floor now this is going to be our jump so if we're on the floor and I click spacebar then I'm just going to jump I'm just going to make our velocity equal to the jump velocity which is 4.5 in this case and all this is moving now this is moving and this is essentially idle if if Direction means if my input Direction in production let's do one at a time so input direction is actually a really good way to take our three keys left right up down and say hey which way are we trying to go right so either we'll end up getting a vector of 2D space so we'll get a zero zero zero one zero two or three uh one zero one one maybe Etc right so 0 1 would be going to the right I believe right so it would print different things or zero negative one would be left or up no down up I don't remember it doesn't matter either way this will give us a 2d Vector okay that direction is just this is just going to basically take our input Direction and as you can see it's just going to make it a 3D vector or a vector three because this guy is a 2d Vector we don't want that we want a 3D Vector so here we're going to transform our thing our um Direction into our input Direction into a vector three and so the y-axis is going to be zero because well let's you want to fly and like there's no reason to fly right so our y direction is going to be zero and then if Direction meaning if if direction is anything other than zero like if if it's actually valid then will actually move so this is going to be the movement right it's a very simple movement but it works and then this is going to say okay if Direction isn't happening then we're just going to move towards zero with the uh attachment of speed so we're going to go from our current velocity to zero okay so what we can do is we can actually go here and say get node character animation player dot play idle it's capitalized actually and then we can also go here and say Play Walk I think it was walk right where's it run yeah it was walk okay cool and so now when we play we should have some animation hopefully yeah there you go so there's our player and so when I walk I start like animating with there that's awesome okay all right so um as I said for the rest of the series I'm not going to be using the this character so I'm actually going to delete it for now and I'm going to remove this animation but um I'm now going to show you guys how to do the minion animation here we're gonna make our character invisible again and so just keep in mind I have another video showing how to do this but I'm going to show you how to do it in this series anyways just so you don't have to click off and then click back onto this series so and it's going to be relatively quick so all we have to do is take our cake character animation 1.2 we're going to drag in our kkit animated character and we're just going to drag him in right under and now we see I think his name is prototype Pete so now again remember how do we make it local I want you to pause the video and do this yourself that you should we've done this a few times so you should be able to do this so on pause hopefully and we'll make local and so now here we see all the things that we need and it's the same setup as before so we even have the animation set up for us so we have the role and all that stuff however this is a problem because we want the skeleton to move not the IP right so let's make him invisible for now and let's zoom in a little bit so what can we see well this is actually his skeleton so if we go to the skeleton 3D and make this invisible there goes the the skeleton because so this is the skeleton that we want to attach to our player so if essentially if we attach this player to the skeleton we'll be able to move now maybe you think okay well I can just do this well not really it doesn't work right so maybe and then maybe you're like oh okay well this is a match so maybe I can do this right not really again right so there's K actually makes this really easy so he's made bones for us so the bones are what usually work with the skeleton so all you have to do is let's attach phone attachment 3D let's create it and we're going to duplicate this a few times I don't remember how exactly how many it is but just a few and all we have to do now is make up one bone for each of these so body head arm left Etc et cetera so let's start doing that let's say a head let's go into order so body after that what's next arm left arm left now I don't think they have to be capitalized I'm almost sure they're not mainly because I'll show you in a second uh hand slot left and Slot left and Slot right okay so now if we read the error it's going to say it's not bound to any bone so we have to actually start doing that so we have to bound it to the head the head to the Head and here if we actually okay so the body let's look at the position of the body if we attach it to the body it's going to move okay maybe not that one let's do the left arm left it's going to move to the arm left and same thing for the arm right it's going to move to where the right arm is and same thing for the hand slot it's going to move to the like hand slot right it's the last one arm right slot and now that's it so let's actually take our node 3D now make sure you don't delete the mesh we're going to delete the node 3D we don't need this I'm going to take our mesh outside here and first off we have to actually make sure that he's centered again in the middle there we go so make sure the transform is zero zero zero zero and now we're going to basically drag everything into the bones so let's take our head and Pop That Into the head let's take our body drag that into the body we're going to take our arm left drag it into the arm and arm right so now let's minimize all these delete prototype P we don't need them anymore bye bye Pete and let's um play a Attack One For example and let's play it and there we go there's our attack that's awesome so we now have an attack that works really nice that's awesome so we now have an attack so that's it that's it so we've essentially animated our um skeleton and so we could do the same thing we're going to actually get started in in player State soon so let's get right into that okay so the first thing we're going to do is I'm going to minimize everything so make sure that you've minimize everything so we have a more organized player and for the camera let's just reset all the transform and rotation and let's go into our actual player and add a node 3D and then in our node 3D we're going to add a spring arm 3D now this is a helper node mostly used in three third person cameras so this is perfect for what we need so let's take our camera and attach it to the string arm now let's take our node 3D and rename it to camera controller now this camera controller will essentially allow us to control the camera so let's add a script to it and hopefully yeah it adds it to our player uh folder and in here we're going to add a function for input so this function is going to detect any sort of input so there's a built-in goodo function that allows us to do that and it's called input so let's just add input and let's get rid of these comments and the ready function we don't need that okay so let's take our spring arm and let's play around with a few things and see what happens so the first thing that we're going to want to do and it will kind of come back to why I did this later is I'm going to take the spring arm and I'm going to put it right above the player's head so you can attach this right on top of the player's head wherever player you're using just put it above his head not inside of his head we'll find out later in a second why now let's see what happens if I take our spring length and just increase it now you see there's a little line there that increases it now the camera doesn't follow it however if I play it should follow it so let's try and see what happens oh yeah there we go so that is the arm essentially that is the spring length of the arm so let's increase this and go back to our game and as you can see it's zoomed out essentially so this will kind of act as our zoom in and out so it's going to be a nice way to zoom in and out now this isn't exactly how we're going to do it yet but um this is a basic idea of how it's going to work so in our game we now see that we have our that's not what I want let's uh make it a little longer so now in our game we have our player now we want to actually make our Mouse enter the game now how do we do that well I lied we're going to add in our ready function again and in our ready function we're going to add this line of code input.mouse mode equals input Mouse mode captured now if we erase this and we say mouse we'll see a bunch of different things so we have confined captured confined hidden hidden and visible so I think visible is the default that's how we usually have it so once we want to revert it back to how our Mouse which we'll do later way later in the series this is what we'll use if we want to capture it and actually have it as an FPS this is what we're going to use so let's try it and play again and now our Mouse should disappear so it's captured our Mouse so that's not exactly what we want to do because now we want to actually have input so what we can do is we can say if event is input input act event mouse event Mouse button we want to do motion so we're going to check for the motion of the mouse now if it is motion let's print motion and see what we get so I want to see if it actually works so if I move if I click nothing happens should happen foreign only if I move my mouse because it's a motion so here we have a lot of things we have position and relative velocity of a bunch of other stuff now what we really want is the relative the relative is what's going to allow us to essentially if they to a vector two right so we have two numbers here so X and Y it's going to allow us to tell us okay which way are we going in the Y and x-axis right so on our screen in our actual game we have a 3D scene but on our screen we see a 2d plane right we see a flat plane in front of us right because you know this isn't VR this is just a regular 3D plane now and obviously if we just look with our eyes let's say our eyes just have a 2d plane that is how we perceive things so we need to use that relative to essentially move our camera around the player now let's say I'm moving to the right so let's I'm going to start moving the mouse now I'm going to move my mouse to the right and see let's see what we get so now we can see that our numbers are kind of increasing here right so it goes uh it went from 1 4 14 right so or from 0 to 14 essentially so that is what we're going to use to essentially move our camera so what we want to do is let me copy this code this line it's going to be a little long but essentially we're going to make a variable called X rotation let's import the sensitivity we've got to do that so we're going to add a variable called sensitivity and this is just to allow us to change the sensitivity of our Mouse later on so we'll kind of have it as five for now so for the X rotation this is going to be the plane X plane right we're going to want to rotate around the X-Plane now we want to essentially rotate take our rotation dot X subtract it from the event.relative dot Y and then we're going to divide it by a thousand times sensitivity because that would give us 5000 because that's going to give us a really big number and then we're going to clamp it between these two numbers so what is clamp well let's actually go here so if you don't know how to do this all we have to do is control and left click left click yeah and then click the value or click the function it'll pop up the documentation which is very useful so clamp Loop essentially allows to give it a value A Min and a Max and it'll take that value and clamp it between those two values so here let's say see this one it's going to give we're going to give it negative one and it's going to clamp it between negative one and five meaning it's going if it's too low if it's past negative one then we're going to put it at negative one right so if it's negative 100 it's going to put it at negative one if it's negative a ten thousand is going to put a negative one it doesn't matter right so it's going to clamp it it's going to make sure that it only hits that minimum or that maximum okay so we want to clamp it between those two because well you'll see in a minute because there is a reason either way we're going to do the exact same thing now for the Y rotation but we're not going to clamp it and you will see why in a minute now what we're going to do lastly is we're going to rotate we're going to create take our rotation and make it equal to Vector 3 x rotation y rotation and zero now zero is the Z axis we don't want to or we don't have to move the z-axis right because we only want to move this way essentially around our character we don't want to move under in a sense so let's play and see what we have and now when I move my mouse it moves around the player now the x-axis the reason we clamp it is because I don't want to keep it going up and down so let's actually take this out yeah let's take this out for a second and what we'll do is we'll copy this and let's not clamp it let's just take rotation let's do the exact same thing as the Y rotation and do it like that we multiply by sensitivity and let's play again and see what we get and now I get a really wanky camera that rotates up and down right because usually in a game we can rotate all the way around on the y-axis meaning we can rotate around him but we don't want to have to be able to rotate above a certain point that's why we clamp it okay so that's why we're going to clamp that value let's delete that line and make sure that we don't get any errors and you can change these values to whatever you want you can try 0.5 these are the values that I found the best you can change it to whatever you want maybe you can try 0.3 and negative three whatever you want right so it'll kind of depend later on later on we'll add graph so you'll see the reason why I chose those values Etc so you can choose and play around with those values and again you can also change around play around with the sensitivity you could always do that so hopefully you understand how we rotate it around the camera okay the next thing is we're going to handle Zoom now Zoom is going to be a little different because the event is not the exact same so we're going to say if event is input event Mouse button then we're going to check which button it is so the way I do this isn't the best but the way I figure out which event I'm looking for so event is going to be any sort of key or or input I give to the keyboard the computer so if I hit spacebar actually it won't print anything because we're only checking for Mouse button okay so let's start clicking so if I uh right click we can see that it prints on the bottom now if I left click well it prints again now see here the button Index this was right click this was left click now let's see it should say button mask was essentially buttoned down and then button mask 0 was button up so there's a bunch of different things on how to check for this now we're going to add an if statement and this if statement is going to basically allow us to see if our input button index is going to be Mouse uh the middle Mouse so if I scroll down you'll see button index is equal to five if I scroll up it should give me oh let's print the event outside that if statement let's play again now if I scroll up it'll give me index four so now we can check if we're scrolling up or down by saying if index input or button index is four or five so this is scrolling down so let's do something when we scroll down we want to say get node spring arm dot spring length looks like someone's at my door I'm gonna ignore that for now sorry about that okay so for our spring lengths we're going to increase it by 0.1 every time I scroll I'm going to take this copy it and we're going to add it here and say negative now let's see what we got foreign and now we can scroll in and out now the reason the one of the reasons there's another reason why let's actually show you why so let's put this inside of his head the string arm and see what we get so there partly ooh it doesn't look like it's happening here so I had a lot of issues with the camera rotation before if the spring arm was inside of his head it wouldn't really work properly and so it would kind of spring back into his head and it kind of created a lot of bugs and I found the only way to fix this and so of course you could do that the only way to fix this was to put it above his head so if you're having bugs with it definitely just put up above his head if you're not go for it you can put it in his head whatever you want play around with it so let's go back to the camera rotation and add a few things because it's not it's working but it's not working perfectly so I've made it so that it's like this so we're going to check if the spring length is less than 10 then we'll keep adding to it now we're only going to subtract from it if we're over 0.5 okay we can actually change that to 0.1 if we want whatever you like so now this will essentially max out at a certain point so I can't zoom out too far and I can't zoom in too close let's actually do like two I think that's a little far okay let's see how far the app there you go so you can Max and Min the zoom you can make these values as well so let's say variable Max Zoom equals 10 variable Min Zoom equals two and then we'll replace those values so here and Min zoom up there okay and that's it so now we can zoom in and out pretty smoothly and it follows the player so I think we should be able to still able to move and yeah so we can now move a little bit and zoom in and out of our player now the player movement hasn't worked isn't working yet but we'll get to that but yeah that's our camera and it's working pretty nicely now one of the main issues later on is going to be the global position because we're going to need that now we'll get back to why we need this later but for now I want you to add this piece of code so I'm going to take our Global position of the camera controller and we're going to make it equal to the player Global position because the camera controller doesn't always follow the player properly in the sense of the position now the position will follow it but not the global position so we want this to kind of be separate from the player in the sense that its Global Position will change with the player let's get started with our animation tree so that's obviously first actually add our animation tree and inside of our animation tree let me just double check which one we need yeah we're going to learn about the state machine so the state machine is what we're going to use the first thing we need to do is activate it where it can't activate it because we need to assign it so let's assign our animation player and then let's activate it now we can see that nothing happens because we need to actually add stuff so let's add a few things and then I'll explain what the state machine actually does so first let's add the idle where is that it might be a little far so we might have to just oh there it is never mind so let's move that right there we can kind of align it let's go from start let's take our transition and let's drag it from start to idle okay now let's add one more We'll add a few so let's add attack where's that shoot attack one hand I think that's all we really need is attack combo you can add whatever you want let's go to walk and then lastly oh I'll still jump where's the jump animation is there one yeah there is perfect okay so if you're using another K kit or another thing you should have all those animations um let's play with this now so now you might notice a problem if you've never used animation treat don't worry we're going to explain it through it mostly mostly four things now when you play it it works here however now let's try playing something else so we see it's already playing the idle I'll start playing the jump it's not going to work because our animation tree is essentially overriding our animation player now now let's try playing the jump that's what our jump looks like okay so animation tree is going to override our animation player because we have our animations in here so now let's actually organize this a little bit so let's have our attack I think we can zoom out nope I lied I guess not okay let's organize this by just putting that there let's put our walk over here and I'll put my jump on the bottom now let's take our our idle and we're going to idle from walk to attack and to jump now okay so let's explain what a state machine is so State machine is essentially a machine that will allow us to go and rotate between different states now the state is essentially the state of our player now if we want to show the idle animation we'll be in the idle State now if I wanted to show the jump animation I'll be in the jump State now if I want to be in the walk animation jump State Etc right or Rock State sorry so that's the idea now now we think okay so how do I want to get from it from Who attack well you would think so let's say you don't want your player to be able to go from jump to attack well that means you don't have to add a transition to that but I want to be able to get to attack from idle and walk so what we can do is attach one from both those so we can go from either idle to it to attack or walk to a back now we want to be able to go from Attack to idle or from Attack to walk right because our player could or the the person playing the game could still have their finger on W or pressing forward right now we also want to go from idle to jump and jump back to idle and we will we want to be able to go from jump to uh walk to jump let me double check that's everything and let me organize reorganize this actually to how I have it on my reference my attack is over here and my walk is on top and this is how I have it organized okay awesome now let's change a few things so first thing we're going to do is on jump we're going to go through the actual transition and you can see on the right hand side we can actually change a few things so we can change X fade time now the X fade time is actually really really cool it allows us to essentially fade between these two animations and blend them so if your animation player that isn't smooth going from jump to idle it'll actually smooth it out for us so that's actually really cool so let's go here and I usually do make this one point one usually yeah in my reference I did 0.1 obviously it depends on the animation you might want to double check whatever you're using but that's usually a good reference because it'll blend it out even even though it's really fast now for the switch mode this is immediate right so there's a few different ones I I'm not 100 sure what sync does I think it just syncs the two together but immediate essentially will go from idle to jump from idle to jump from jump to idle Etc and it won't play the actual animation now at end will allow us to play the animation and then go to idle and then yeah so you can see that it's going back and forth because this transition is immediate right now I think what do I want to do we want to take this and we want to take our mode and remove that and let's go to walk this guy let's go to our auto mode and take that off let's go to this guy and switch that off and that's it so now we're going to be sucking the idle mode now it'll only travel between these states unless we ask it to so let's actually go through all of them and turn them all off now the only other one we're going to switch at the end of the animation is also the attack animation so let's go to the switch mode and change that to at end and then let's go to auto actually this will be on auto because when we play in our game I want it to automatically finish the attack animation and go back to idle we don't have to worry about switching it manually now the other ones we're going to have to worry about so let's turn off auto for all of them now if I didn't what would happen especially for like Idol to walk so let's turn that back on and see what happens it'll go to a walk right it'll automatically finish idle or actually I don't think it'll even finish let's play it okay I don't think it finished it and it just automatically goes to walk so we have to make sure that that's disabled and I forgot the transition from walk to idle so let's add that and sure we switch that off okay so that's our animation tree all set up let's test it a little bit let's go into our animation player and let's add a few things so the first thing we can do is we can actually Auto load or load a few things so I'm going to autoload these two things and you're gonna hopefully copy it so we're gonna on ready variable animation tree and we're gonna get the animation tree and then we're going to also load the playback now the playback is the animationtree dot get parameters slash playback now this is it's not it's hard to find here but it's essentially that's true parameters here we go parameters playback here it is so it'll get this entire playback as a node almost and now what we can do is we can say in Direction here let's say way back DOT travel to idle no that's when we're walking so let's actually make that walk and then what we can do here we can change this to idle and now let's play and now when I move or when I'm not moving you can see he's idle and now when I start moving it doesn't matter what direction he starts walking right which is really cool so now we can travel between those two states because we're manually doing it because the travel is essentially telling our our animation tree we're going to automatically own automatically we're going to manually switch to walk and then here if direction is zero essentially and we're not moving we're going to manually switch back to idle right so let's say I switch to attack or jump actually let's actually do that let's go here and go to jump now this won't work properly because um I'll explain why in a second let's just try and see if it works and let's jump and there you go so he should play the jump and go back to idle automatically I don't have to travel to the to idle because it automatically goes at the end of the animation right and there we go so there's our cool little jump now we'll add we'll make it smoother later on and add different ways to do this but let's add this back in and see what happens it shouldn't work but if it does that'd be kind of interesting okay cool it doesn't work that's good well it's not good because that's not really what we want right but it's kind of expected now why is that happening well because what's happening is physics process the computer is going to read this code in in this direction right from top to bottom and it does this every like second it does it more than once a second right so it's going to always be checking for this jump and then it's going to go down and it's going to be checking for this input now if I do click input right if if direction is valid meaning I am clicking something then I'm going to be clicking I'm going to go to walk now if I'm not doing anything I'm going to go to idle but that means it's going to override this now if I take idle out should work hopefully let's try it yeah so it should it will essentially go from walk or from whatever it is to jump right because it's not going for too idle what is actually happening I believe is it'll be going from walk to jump which is allowed right because we have a transition there so this isn't the best way to do it so we're going to actually delete this and this is just a good way to understand how it works next time we'll be on the next video all right or in the next part we'll be learning about proper State machines and we'll actually manually add in our own State machine to essentially travel through the animation tree as well so we'll have an as a state machine not only for the animations but for the player as well so keep in mind a state machine let's go over the definition of a state machine again a state machine is a machine with States obviously that allow us to go in the animation and specify which animation we're playing at a time okay so one state is Idle one state is walk now if we're in the walk State we are going to play the walk animation now keep in mind this is an animation tree meaning it only cares about the and the animation state it doesn't care about the other things right so we're going to manually do that later on so hopefully um you can stick around and we'll get right into that okay so the next thing we're going to do as we said is we're going to add State machines so let's create a folder for this because we're going to have quite a few scripts so let's create a folder called scripts or states and then in this folder we'll create a new a few scripts the first one we'll call it state uh we'll do state Factory like that and then let's open that script we'll open up and then let's duplicate it and we're going to make a few more States before we actually get into coding anything so we're going to call one state any file Ctrl D to duplicate we'll say move State uh I'll capitalize it right I didn't capitalize in my reference I'm going to try to keep it as accurate as possible I'm going to make move State we're going to have idle State and then we're going to have a tax state and we're there's a few States so let's hopefully actually go through those so we have it's attack we're gonna basically make the states that we have in the animation tree so we have move State et cetera Etc and then in the we also have a jump State okay that's all four states so far so I'm not going to go through every single state that you would want in a game however I'm going to go through the basics so the first thing we're going to do in our State Factory is we're going to create a class name so here we're just going to say class name as state Factory this will allow us to basically create a node it's a new node a new class right so if you don't know what classes are I would suggest looking up other videos I'm not going to go through it in this video but um it's definitely a powerful tool that you'll want to know so definitely look up State or um classes and class name in Godot if you don't fully understand it okay the next thing we're going to do is in the state Factory we're going to hold States in it now the states we're going to initialize it at launch so we're going to say a function in it which is initialized we're gonna uh say idle is equal to idle State attack State and we're going to remove false State and hit and death State we don't have those so we're going to remove those so now we have attack move and jump now here now none of these exist because we haven't made them yet so let's ignore the error and let's go on so let's actually move that there and now we're going to create a function called function get state so this state will essentially allow us to just return a state now essentially what we want to do is it's this so return get State uh State oh sorry say return States dot get a state name so this is a dictionary and a dictionary has the function get so I think we should be able to say dictionary okay awesome control left click and we shouldn't see this pop-up it's the documentation for it and we should and we can look for it by saying Ctrl F and say get and we can look for the function and here it is so we're going to say get key now there's uh we can actually just look at this and we can read what it does it essentially Returns the corresponding value for the given key so in our back to our C Factory what this does is it's going to just return whichever State we're looking for now what we want to do to avoid any errors is we can check for it first so we can say if States dot has the state name then we'll get it so it's just a quick way to avoid errors obviously this shouldn't really it depends it shouldn't happen often but if it does ever happen let's say if you release your game it won't give you the player an error it won't crash their game because we're going to check for it here right okay now let's actually get into this and hopefully unair this right because we have a lot of Errors now what we want to do is we're going to go to into each state so let's go into our idle State first here we go so idle state let's open this up and we're going to say this extends State and it's a class name idle State now extends extend essentially is like a child or a subclass of state now we have we didn't make this yet so let's actually do that first let's go to state and we're going to say in state we're going to say extend node and class name state so again Cloud this node is going to be the class State that's the noon class for this state right let's I'll try to keep track of everything I'm going to try to help make sure that you can keep track of everything okay so extend node 2D is essentially going to allow us to to take on the Node 2D properties and have a node 2D now you'll see why we do this in a minute I'll show it through the actual nodes but essentially what we're going to do is we're going to create a node 2D you could do 3D if you'd like it doesn't really make a difference because it's just holding values in fact you could just do node I don't think it really matters but it's just going to be a node that exists here as a node so it's going to be as if we actually manually go here we're going to say node 2D whoops that's not a node as if we added a node 2D and then we're going to put stuff in it now what do we want to put let's put these three things so we're going to have a function called change State we're going to have animation and we're gonna have persistent state okay now for the setup we're going to have to have a function for the setup so we're going to say function setup is going to essentially help us set up change State animation Etc now this is essentially a node that holds these three things these three values that's it's going to allow us to access whenever we want okay so no matter what state we're in whether we're in Idaho State we're going to be Every Idle every state will have these three things okay every time we set it up and we'll go through setting up a state later on so in our idle State we can now extend the state so again this extend is essentially going to tell us okay we're going to extend the state so we're going to take the properties of this guy right the last name State and we're also going to make our own class name called idle State okay so this is also its own Idol or state called idle State okay so now if we actually go back to our state Factory we now see that this is um greened out a little bit that means we've created it so now what we want to do is let's go into here and we'll go into our tax date and do this for each one so we'll say attack tax state to jump we'll say jump State and then move State we'll do the same thing and say move State okay and now if we go back to our state Factory and save hope we should on air or avoid the error expression dictionary key sometimes it doesn't work perfectly I also might not have written it perfectly okay oh there we go that's why okay there we go so now we have no errors awesome now in each node we have a uh a state now in each of these states we we can do things now we're not going to do anything yet let's actually create the node that we need so in our um warrior in our player we're going to create a function called change state so this function will allow us to essentially initialize every state or change States okay so change state DOT new state name let's enter a few times we need to essentially initialize the state so the first thing we can do is say state is equal to statefactory dot get state with the new state name dot new now this obviously isn't going to work because there's a lot of things wrong here first of all we don't even have variable state so we would have to initialize that and we also don't have state Factory so we have to initialize that we have to say we'll put it up here somewhere awesome so here we'll say State variables State and State Factory another issue is that we haven't created State Factory right so we have to actually create the node so we'll do that in a ready function so we'll say function ready we'll say state Factory is equal to state Factory dot new and this will essentially allow us to create the state Factory node okay now here we're going to say state is equal to statefactory.getstate so now if we go back to State Factor here we have get state with this thing right and inside of our player we're going to pass through this new name and we're going to create a new node with that okay so essentially we're going to create this new node so we're going to say we're going to get so here we said get state so let's say a pass through idle right so here it's going to say idle name it's going to check if we have it if we do have it it's going to return idle it's going to return this the key right it's going to return the actual state so it's going to return this class so it's going to go into here so now in our player we have we have access to the class right so state is now equal to idle class right as long as I pass through idle now what do we want to do with that well we actually want to set it up first so let's say state.setup is equal to change State playback and self now the playback here we're passing through the playback mainly because I decided that's what we use the most you could pass through the animation tree instead we'll get into it later on and you'll kind of see what we can do but for now we'll leave it as playback because we're going to pass through the animation the playback essentially okay and self is going to pass through the actual player so that we know who the parent is okay now this is kind of my own thing and this is kind of for you guys we're going to name the state we're going to say the node the state DOT name is equal to the actual named US state now if we don't do this the name the node the name of the node will be really weird so um we'll we'll test it out and we'll see what it looks like so lastly let's add the child and that's it so let's let's test this out and in our ready function what we can do is we can change state to idle so let's change State automatically on ready to idle else play hopefully we don't get an error awesome no errors now let's go to the remote and find our player and here we can see the idle now let's end this and test a few things let's get rid of the name and see what happens now I think it shouldn't work too well okay there we go so there's no name the name is is a bit wanky now I did I so gameplay wise and code wise this does nothing um for the player the person playing the game it does nothing they won't know because they can't see this but for you and for debugging purposes and for me teaching you hopefully um this is I added this okay so this isn't necessary but it's something I've added now this is great and all but what if I change States again so let's let's actually do this twice let's say change state to idle and then to run I don't know if run is a thing the walk let's do walk let's play again and see what happens okay so it's going to err first of all I think it's actually because we don't even have walk we have moved that's why okay so let's go back into our thing and change to move so there's a few reasons why we aired there okay so in a remote here we go so here's our second issue first of all we now have two states that's not what we want we don't want two states at a time we only want one so before we add the new state this is adding a new state so let's add a comment uh uh new state before we do that we want to check for the current state okay so we're going to say if State not equals null then what we can do is say state DOT exit now I'll tell you what this isn't in a bit and then we're going to say state DOT Q free this is the main part that we need in fact we can actually get rid of this and it'll work fine so let's play this and see what happens we've changed in our ready function we should have changed from idle to move automatically right so in ready it's in a row so we should now only have move awesome so it works now this is a bit of stuff that I do now what is this this allows us to call a function called exit before we queue free now the reason I do this is because it's very useful to know when a state is about to end so in each of these we have to we have to um let me go to my reference we have to create a function in each of these called function exit so we have to go to all of these and say function exit function exit and attack State function exit now here we can essentially say Okay print exit attack States let's save this let's go do the idle and let's print exit idle State now let's play and see what happens and it should print exit idle State now this is again this is just really useful to know the node will know it's exiting before it gets destroyed okay so this is a useful strategy that I use to essentially let the node know it's about to be destroyed or too freed okay you can also do this let's say if you before you add it you could also call a start function or a ready function and usually you don't have to because there's already a built-in ready function but there's no built-in exit function right in Godot that doesn't exist so we can make our own so it's very useful so yeah that's about it for the state functions in the next um part we'll be adding the we'll actually be implementing the states and switching this between the stage States and implementing the animation tree so stay tuned okay so last time we've implemented our states and then this time in this part we're going to to do things in that state in those States so for example when we move I want to move these things into our move State now there's going to be a reason for this because now we can actually animate it in the states so first let's actually move it so this is going to be a little hard and a little tricky because my reference doesn't exactly have what we need but we're going to figure it out together so here's what we're going to do we're going to leave the direction here and then we're going to take this and copy it into our move state but in here we're going to obviously need a physics process I'm going to say if Direction now we're going to get a bunch of Errors now the main reason is because first of all direction is not here and even if it was it's not the player so the first thing we're going to do is we're going to say variable player and that's it whoops that's not what we want to do then we're going to say function ready and then we're going to say player equal to get parent now the parent of that this node or the state is going to be this player is going to be the player so so now what we can do is say if layer dot direction if player.velocity player dot whatever and we're going to have to add this to each thing so we're gonna have to say player dot whatever player dot speed player dot speed dot we gotta add a DOT and Etc so hopefully that'll avoid all our errors and this is basically going to reference each thing so we're going to change the player's velocity we're going to change the players um or we're going to reference the player's velocity reference the player's speed all these things okay and now we should have no errors okay and now what we need to do is we need a way to change to the move state so the first thing we're going to do is we have to first check okay so this is moving this is not moving so this is actually this actually belongs in the idle state so here we would say Punk physics process and then add this so again it from the move State though we need to do this so let's actually copy this part into the idle state there we go so now we're going to this is the idle State meaning so if we're not moving this is what we should be doing so we're just changing our velocity x and z to zero right over the time of speed so it's it's a very simple way to do it um I think I changed it later on but for now this is good enough okay so in our move state um else here instead what we're going to do is we're going to say layer dot change state to idle right yeah okay perfect so now we need two things the first thing is let's actually add an animation so here what we can do in our ready function is we can say animation Dot travel you walk I think and actually what did we name it let's see yeah walk so here this is going to this is remember the animation this is a bit confusing because I kind of messed up the naming a bit but the animation dot is the playback because remember in our change State setup we pass through the playback so we're essentially saying playback DOT travel okay so back to our move state I'm going to say playback DOT travel to walk now we can do the same thing in our idle state but say dot or travel to idle now this is actually a really good way in the animation this is a really good way to visualize what we want to do so we want to be able to go from idle to walk now in our idle State we have to add something that allows us to move or change to our to our move State now what is that well we need to add essentially an input check so in our physics process what we can do is say if input dot is action pressed now let's actually do this real quick okay let's add our own input so uh let's actually avoid the error and say walk right I think I'm going to do is action pressed actually not is action just pressed I want to do this and we're going to say layer dot change state to walk first of all we don't have a walk right so let's add all the things that we need in our info map so let's go to add new action add walk right walk left lock down and walk up there we go okay now here let's actually add everything so let's do uh walk right is probably not going to be that I don't know why I did that hold on let me delete that walk right will be D walk left will be a walking down we'll have it as s and then walk up as w we can also do the regular things and do down has a physical key and then walk left is left and walk right and or key as walk right okay cool so now we have the movement okay so this is only walk right so what we want to do is we actually want to take this and say or walk left or walk up or walk yeah I think that's the last one okay so now if I press anything it's going to go back to change to change it's going to change to the walk State okay so here we have a way so let's let's restart let's focus go back to the ready State here let's take this out actually we're going to automatically unready our player is going to change states to idle so we're going to go into the idle state right so imagine this is this is a really good way to visualize it this isn't actually what's happening but it's visualizing it for us so we're going to start and we're going to go to the idle State now in the idle State we can we want to go to walk right so this little transition here we want to be able to go to walk now we have to code that walk right we have to be able to change that manually we have to do it right and to do that what we do is we check for input uh wasd right and if we do then we're going to change to walk now in the walk State what do we want to do from there well ideally we want to be able to change back to idle if we're not moving anymore now player direction is a really good way because the direction is just going to be zero if it's not right so if it's not if it is zero it'll change back to idle so this is a very good quick way and little dirty way to change back to idle okay so I think that is almost all we need in there let me just double check yeah it looks like that's it so let's give it a try and see what happens let me actually double check here yeah let's give it a try and see what happens okay we got an error already nice okay what do we got non-existent function I might have um written something wrong so we're gonna have to make sure we see in idle that's why let's move not walk okay all right and one more time we've got another error in value index direction if the player Direction um let me double check okay watch the error here invalid get index Direction character okay I think I see the problem here we're gonna take the input Direction instead so let's go back to Player move State we'll say input Direction Let's see if that works okay nope okay let's do this together invalid get index input Direction okay sorry about that okay so we need to make this Global in a sense so we need to take this direction and put it outside of the physics process so we'll say we'll put it right here variable Direction and let's go back to our move State and say Direction okay there we go now that should work and now when I move it's very buggy but it should move slightly okay so what is happening well what's happening is that it's always it's going okay so what's happening is it's going from idle to move and then it's going from move from move state to idle State now the reason is because of this so let's take this out and see if that works okay okay so the first thing we need to do is actually loop our walk animation so let's go to the walk animation walk walk let's Loop that and play One More Time okay there we go we are now looping now the direction movement is not actually working but that's okay so this is not working yet but we'll Implement that in a second so let's add back this guy the change State and we need to now change the way we walk because this anime this state or this velocity is using this direction it just isn't really working anymore so we're going to actually change it anyways to actually fit our um direction using our camera so let's actually just do the interaction for now and then we'll use the camera later to kind of adjust our facing so first of all let's just comment these two out and what we're going to do is we're going to say Direction equals and this is actually very easy we're going to make a vector three back four three a vector 3 vector and in this Vector it's going to be a little long but hold on with me so we're going to say we're going to take our input get action strength walk left we're going to say minus the input walk right okay now we're going to say 0 because on our Direction on our y-axis we shouldn't be moving right we're not jumping right so the direction is only on the black plane as if we're walking like on a flat plane right now I want you to guess on this z-axis what is it going to be it should actually be very similar to this but it's going to be the down and up um inputs so let me just copy this real quick so in here we'll have the input get action strength walk up minus the walk down okay so essentially here what we're going to have is why if if I'm clicking left walk left right it's going to say 1 minus 0 which is going to be one right so we'll end up with Vector 1 0 0. now if I'm clicking right I'll end up with negative one zero zero and then on this one if I'm clicking up I'll end up with 0 0 1 right so try to visualize this in your head a little bit but that's the basic idea and now we can now let's play again and try this and let's see what we get so now our bugginess is kind of gone it's not jittering anymore because it's not switching from it's not switching its direction often anymore okay there we go and so we now switch from the move state to the idle State now if you can if you're noticing you can see that the player is going from move state to idle State really fast now this goes back to what I was saying before so in the animation tree we can actually take the X fade time and make it 0.2 and same thing for walking we can say 0.2 or 0.1 whichever one I like 0.1 but I'll do 0.2 to hopefully show the effect a bit more so now when I walk it's gonna fade back into the original animation it's not going to be a cut it's a little smoother now okay awesome in the next video we'll work on actually getting our player to move in the direction that our camera is facing Okay so we need to now change the way we walk because this anime this state or this velocity is using this direction it just isn't really working anymore so we're gonna actually change it anyways to actually fit our um direction using our camera so let's actually just do the interaction for now and then we'll use the camera later to kind of adjust our facing so first of all let's just comment these two out and what we're going to do is we're going to say Direction equals and this is actually very easy we're going to make a vector three effect four three a vector 3 vector and in this Vector it's going to be a little long but hold on with me so we're going to say we're going to take our input get action strength walk left we're going to say minus the input walk right okay now we're going to say 0 because on our Direction on our y-axis we shouldn't be moving right we're not jumping right so the direction is only on the black plane as if we're walking like on a flat plane right now I want you to guess on this z-axis what is it going to be it should actually be very similar to this but it's going to be the down and up um inputs so let me just copy this real quick so in here we'll have the input get action strength walk up minus the walk down okay so essentially here what we're going to have is what if if I'm clicking left walk left right it's going to say 1 minus 0 which is going to be one right so we'll end up with Vector one zero zero now if I'm clicking right I'll end up with negative one zero zero and then on this one if I'm clicking up I'll end up with 0 0 1 right so try to visualize this in your head a little bit but that's the basic idea and now we can now let's play again and try this and let's see what we get so now our bugginess is kind of gone it's not jittering anymore because it's not switching from it's not switching its direction often anymore okay there we go and so we now switch from the move state to the idle State now if you can if you're noticing you can see that the player is going from move state to idle State really fast now this goes back to what I was saying before so in the animation tree we can actually take the X fade time and make it 0.2 and same thing for walking we can say 0.2 or 0.1 whichever one I like 0.1 but I'll do 0.2 to hopefully show the effect a bit more so now when I walk it's gonna fade back into the original animation it's not going to be a cut it's a little smoother now okay awesome in the next video we'll work on actually getting our player to move in the direction that our camera is facing okay so welcome back let's get right into it and the first thing we're going to do is we're going to jump back into these states so we're going to want to implement all the animation States now now to do this firstly let's first actually be able to rotate the player so this is actually pretty simple and it's about two lines of code so the first thing we want to do okay all right it's about to be four lines of code the first thing we want to do is we want to be able to turn our Direction into the direction that our camera is facing now to do this we're going to need a variable called H rotation so right above the we need right here so let's put it right here so we'll say variable H rotation or Road we will get the camera controller so we can say you just drag it in and say camera controller I'm going to get we're going to say transform dot basis dot get Euler hopefully it fixes Euler I think it's like that dot y okay so what is this let's take a look let's go to camera controller let's actually go to our camera I think will it be here I think it'll be in our camera we search up the Euler won't be there okay here we go sorry there it is so rotation edit mode Euler so this will return us a vector three and we're going to transform it into a 2d scene or we're not going to transform it into a 2dc we're going to use that as a direction okay and the transform is generally the transform and the basis is it's not here but it's the basis of our node so it's going to help us actually get the direction of the node okay or the direction that the camera is facing okay so now what we can do is we're going to say Direction equals Direction and rotate it so in order to take our Direction with the current input we're going to have to take our input and then rotate it based on its previous input direction right so let's say if direction is Vector zero zero zero we're not going to do anything to it because it won't matter right now however if we have like one zero zero then we want to actually rotate it so to do that there's a function in good o that helps us do that pretty easily it's just dot rotated and we're going to rotate it on the vectors 3 up and H rotation and then we're going to normalize it normalized this will allow it to just be a better cleaner number so that Godot doesn't get uh jittery okay next up in our move state this is a little line of code I'm going to just copy it here and I'll explain it so here instead of the player we're not going to rotate the player I had a lot of issues rotating the player so instead we're going to rotate the mesh and this works pretty fine mainly because it doesn't matter if the player itself is rotated or if the mesh is rotated because either way the player will move in the direction of the mesh so we're going to rotate the mesh rotation we're going to Loop it to the angle that is currently our Direction okay so we're going to take its current rotation and then turn it to this whoops this direction okay and then we're going to do it at this speed so you can increase the speed if you would like but this is the speed I found was kind of good and okay so lastly let's make sure we have the mesh loaded which we don't so let's do that so we're going to load the mesh by adding it right here I'm going to say on ready variable player mesh equals get node Warrior okay okay not Warrior we're gonna do um this guy whoops and like that okay so we want to load the node 3D you might think we'd have to load the skeleton or something else but now we're just going to load the node 3D kit so let's play and see what we get and now when I move it's completely flipped so let's actually what's happening is our camera is flipped so let's flip the character actually rotation we'll say 180 okay there we go try one more time nope that's not what we want to do I think we rotate the player itself so let's go to the transform here we'll rotate the player or we can end up rotating one of the children I think nope okay let's rotate this guy 180 there we go okay so let's rotate let's keep that zero and rotate the animated character instead so now when I try to move and look when I press w it'll go in the wrong direction now because I rotate it differently but you now see that the player rotates properly and everything's reversed so we'll fix that in a second but the player now if I click W the player will now go backwards in the direction that my camera is facing so what we can do is we can actually just go here and we can say let's double check to see if the right and left are also reverse let's see write is also reversed okay so what we can do is we can just reverse these and and this one behind here and then make sure we get that negative and then reverse this one as well so if you're having any problems with this this is one option I think there's another option which I wouldn't really recommend it would be to just reverse the polarities of the direction Itself by saying negative Direction but I wouldn't recommend that all right so it's kind of working but the animations are still wrong sorry about that we're gonna not we're not going to change the input um so we're going to keep it as it was so walk left minus walk right and walk up minus walk down instead of the instead of rotating the K kit animating character I'm gonna keep that at zero same thing here we're going to keep the rotation at zero and instead we're gonna rotate the spring arm either 180 or one negative 80. they're they're pretty much the same so make sure to rotate the spring arm if you're having the issue where the player is facing the wrong direction and now we have the player moving in the correct direction so now when I go forward and press W it'll correct itself and do that awesome so now let's continue on in the jump State because I think that's the only thing we haven't done so let's actually take this out and say pass instead of printing something every time so to go to the jump State because we don't even have a way to do that yet we have to actually be able to go there so in our animation tree here we see there's two different ways to go to a jump state from idle and walk so let's do idle first so in our idle State we're going to essentially add an input check right and this is really easy so let's actually add our input so let's go here and add a new action called jump and while we're at it let's just add another one called attack with two T's and not three and jump we'll say spacebar and then attack we'll say Z all right let's close this and now we'll say if input is action just pressed I think we can do just press that's fine and then jump and right player is on floor then we'll jump now we go back to our main character and we see here that this is pretty much the same thing we have here because we have to make sure that we check if we're on the floor so let's copy this and delete this let's delete the handle thing as well so here let's say player dot change state to jump okay because here we don't have to jump because we're going to handle the jumping in here right so now in our jump state let me just open up my reference for the jump state so let's add a ready function so function ready let's pass for now let's add a physics process function and then in this physics project process we'll add a few things in our ready function first of all let's add our player so let's say variable player so we have access to our player and then in our physics process we're going to add a new code or a new piece of code that's going to allow us to jump but it's going to be a little different than what we had before I'm just going to be moved towards so instead of setting the velocity we're going to add it add to it over our process function so we're going to say move towards so we're going to take our current player velocity and we're going to move it towards the jump velocity instead of just setting it equal to it and then we're going to go to the speed of this negative divided by 50. you can set a certain number if you want but I found this is pretty nice because you can if you edit the jump velocity this it will kind of switch the speed it goes to as well so let's say you don't like the jump velocity let's say JUMP velocity of 4.5 is too little and you change it to seven this will adjust itself and jump at the same speed or a similar speed okay now we want to be able to switch back to idle because in our jump State we have to we've moved to jump state but we have to be able to go back to jump State as well so this is actually really easy to say if player is on lore then we say player Dodge change state I don't now why does this work well because in our jump State it's going to be constantly checking if our player is on the floor or not right because the only time we're in the jump state is if we're jumping right and so once we've jumped we want to just check if we're in the auto state or not and that's it so I think that should work so let's take a look and see if it works let's try and let's jump and nothing's happening okay so it's silly I realized that the jump velocity uh 4.5 was too small and um we now need a bigger one so there we go there's our jump it was working fine we just need to increase the number of the jump velocity so I did 200 we could do maybe like 300 let's see what we get so it should be a little higher yeah there we go so now it's smoother jump okay so in our jump State there's one last thing we're going to do let's remove the print state I like to add a animations uh function so I'll say jump NM and then here in this function we'll say player what is it I don't want to mess this up so yeah we just say animation DOT travel to jump and here we go okay so let's see what we got let's play again and if I jump I'll play the animation jump why is that do we have the animation jump we do travel to jump let's see player oh I actually want to call that function that's probably why that'll probably help us actually play okay let's try that there we go okay there's our jump now the reason I have the await okay hopefully you didn't see that the reason I have that is because as you see in the game it's not very smooth right it doesn't really jump the moment I jump like the animation and the jump itself are not in sync so the what what I did is I just await 0.1 seconds so we say a way to get treat dot get timer point one dot timeout now if you don't know what a weight does it's pretty much just gonna tell our code okay we're gonna wait this amount of seconds before continuing now this amount of seconds can be anything it doesn't have to be a timer sometimes it can wait for something else like a signal right so for example if our animation played in animation frame so um animation tree doesn't have that but let's say I said player animation player changed that could be a signal as well right but for here we want a timer so let's test this and see if 0.1 seconds is enough it's not so let's see let me show you the way I did this and know where the timer would be so first of all we have to turn off animation tree and we're going to zoom in and we're going to go to animation player and we're going to go to our jump we're going to go through it slowly we're going to see where he actually starts jumping it's about 0.4 to 0.5 So at around we're gonna wait around 0.4 seconds and let's see what we get so let's actually make our tree active again let's see what we got and there we go now he looks a lot smoother and actually jumps when the player is supposed to jump and now all we have to do is we can say in our idle State we'll copy this and we'll go to move State and we'll just add this right here into our physics process and now when I play I can move and jump while I am moving there we go and remember in our animation tree there's no way to go from jump to walk now if you want to you can do that but I'm not really sure I guess you could you could check for the velocity so if you wanted to go from jump to walk which it doesn't really matter because what's happening after the jump it'll go back to idle and if you're in movement or if you're moving in idle it'll go to walk right away but if you want to go from jump to walk directly all you would have to do is go into your jump state and instead of just checking for is on floor you can also check you can say uh I'll just write pseudo code so I'll say if um player velocity velocity and not equal zero then change to idle or etc etc so that's a good way to check if you're moving or not okay so but I'm not going to do that so if you would like to do that go for it okay last thing before we change to the next part is Let's Make a way to go to the attack state so let's go to our attack State let's copy these because when I need these go into our tax date and add this so I'm going to say attack anim and we'll travel to attack one h under capitalized there we go and we'll copy this okay and now let's yeah let's add a physics process so we'll say physics process function it will pass for now we're not going to add a way to move back but in our idle state what we can do is we can copy this and then say attack uh attack attack and then we're going to check for the attack button and now let's see if this works so from idle to attack and there we go he moves to the attack State now we can't do anything again because well you know there's nothing going from the attack State back to idle so let's add something real quick in our attack State I want you to think of a way to how can we go from Attack to idle how can we check for that okay okay so in our attack State there are probably good some ways to do it we could do a weight we could do whatever but the way I did this was a little simpler what I did was in our animation tree instead I just selected the animation finished connected to our player and then in here I just check if the animation that finished was the anime it was attack so I say if Adam name is equal to attack right then we'll change to idle now that's one way to do it another way to do it is to manually uh connect the signal to the animation tree I don't usually like doing that so I I'm pretty lazy and I like to do this instead but that is also an option so in our text it you could manually select or manually connect the node and check for this signal a weight could work as well but I'm not going to do that so yeah let's do that okay so let's play and see what we got close attack and nothing happened I think the reason might have to actually be okay it's not looped let's go to Let's debug this a little bit because I remember there were some issues I had with this so let's print uh it's not going to be a tag it's going to be attack one h okay one h okay hopefully that should work okay we'll have to restart and now we should be able to move again so attack and attack and we can move okay now one problem you might notice so in our move State let's go to our idle now let's say I want to attack while I'm moving that's great so let's copy it and that should be it right however there is a problem so let's move attack while I'm moving so while I'm in the move State and I attack I'm going to keep moving because my velocity is set and I'm not setting it again in my attack state so this is actually a pretty easy fix what I do is I just set the velocities to zero on ready so here I'll set them both to zero and that's it there's no reason to do anything else because once it's set to zero in the attack State there's it's going to go back to idle and an idle state it also has nothing it says or it moves also to zero but if I'm ever moving again then it'll reset it back to whatever I want it to be moved to so now when I'm moving I'll stop moving and attack okay there we go so that's our those are that's our states welcome back so let's get right into the tile map so first off let's close the player we don't need that for now and here let's go back to our main world we have our regular static body floor but and it's nice and all but we want to make the scene a little prettier so let's um create a new scene I'm going to create a 3D scene I'm going to name it Library I'm going to add a static body as tick body we're going to add a collision shape to it and obviously we're going to want to probably add a collision shape to it so let's just add a regular uh square box and let's go into our files and look for some assets so we'll look through this together so we have a lot of banners we have let's look for flooring so we have barrier which is cool corner so we can actually just look up floor hopefully Okay cool so we have floor we have for uh dirt there's a lot of cool stuff um let's look for something there isn't really anything outdoorsy but that's okay let's look for wood large no we don't want a large decorated nope let's actually get the tile that one looks nice so let's take a tile not Arch it's a floor tile and that should bring us up the tiles so let's look for this one there we go okay so let's take the floor tile small and use this as our regular floor plane so let's put that up here and now what we can do is put the static body inside of this nope actually sorry I lied we're going to make this local and we're going to take the mesh out and we're going to delete these new 3D and then we're going to drag the static body into the mesh now let's turn on smart snap let's reset the position and just move it downwards like that and now let's take this guy and move him right there and now let's go back to our Collision shape we're going to turn off Smart snap we're going to move this down to hit the square just so that it's the same size as the flooring and then let's expand it to match the floor itself and hopefully try to just match it as best as we can if we go a little outside it's okay because we're going to be duplicating this anyways okay let's save this in our main scene let's look to maybe add a few other things um what else will we have we'll have small broken Maybe you can kind of just go through it and add whatever you want I'll add this one so let's duplicate this and say lortile [Music] decorated I might add some a few you know what we can do actually I think we should just be able to where'd it go yeah no we can't do that we'll take the decorated we'll pop this in here right here like that and then pop the static body delete this delete this and now we need to move the static body as well so let's actually take our snap though and reset it there we go so now it's smart snap okay now we have to make sure that this is a pixel perfect so that's why we turn on smart snap so that it snaps for us if we look at the position it's going to be at three zero one which is pretty much perfect and now what we can do is we're going to go to the top left scene we're going to go export as mesh library and this is basically going to create a mesh library from our scene okay so let's export it and we can say merge with existing but there isn't one anyways so this is okay we'll say library now if we close this file we should be able to see library.tres now if we double click it it 'll bring us these two things in items now in here it has the built-in static body so it has collisions which is really nice so let's double click the library again and it also has the mesh library that we have or the mesh that we added in to it okay all right so now what we can do is let's make this invisible for now and then add a tile map no not a time up a grid map sorry a 3D tile map essentially now what we can do is just drag in our library into the mesh library and there we go so now we have our floor tiring and now we can just drag and draw our floor now this is pretty tiring so what we can actually do to make this easier is to hold shift click and drag and then Ctrl F to fill and then we can kind of just put the decorated or tirings randomly Maybe a little bit of uh decoration okay and now let's play and see if it Glides awesome it collides and we don't go through the floor so if you didn't add the static body you would most likely go through the floor let me actually delete this to make sure that it's not just that and it's invisible it's actually the floor okay cool there we go we have a little nicer flooring and off video I will probably add a few other things like walls and whatever so um I would suggest you go through the tile map or the grid map that we have and do that on your own I'll probably make these scene just a bit prettier and I'll probably show you what I added but I'm not going to do it right now so um one two three okay so let's get right into it um this is the scene that I've made um basically it has three layers as you might want to call it we have floor walls and Mists so here I've just created a new library full of Mists and this is the live this is the scene I've made so if you want to download this I'll probably leave the final product as a GitHub link so you'll have access to this in the end but for now I want you to be creative and create your own scene okay so let's actually add some life to the game so we're going to be adding a uh torch so let's create a torch light and if you're using another asset pack or something else we'll be using um you can use whatever you want maybe a um something fire related so in my case I'm going to be using a torch I'm going to probably yeah I'm going to use the mounted one so let's basically do this let's drag it in make it local and then we'll right click the torch and make scene root and then we'll just delete the node 3D or you could have just dragged it into the scene instead of making it a 3D scene but uh whatever don't worry about it so let's just adjust this so that it's kind of right there let's look at the transform see where it's at I think we can set that to zero and that to zero or not let's set it to negative something okay and let's just move this up a little bit to be flat it doesn't really matter because we'll adjust it in the main scene anyways but I just try to keep it somewhat centered okay so let's save this as merch and let's create a new folder called objects and then in this folder we'll just save the torch and in here we're now going to learn about particles let me just rename this to torch and so now we're going to learn about particles this is going to be kind of fun because there's quite a bit to this so let's add a particle thing so we're going to search up particles and we are going to use the GPU particles so as you can see there's quite a few but we're going to be using the GPU ones so I think the main difference between these two is that this uses CPU and this uses GPU so let's add this now for the oh what did I click okay that's just the mesh okay so for this we're going to need a few things so we're going to need um some surface area things now for that I'm going to add it probably to a Google doc folder or either get you to download the beginner GitHub link so definitely check that out and you're going to need to download those so I'll be right back and download them myself all right so let's get right into it now that we have the two um things that we need we have fire.tress and these smoke frames oops I don't want to add that in we're going to get started right away so for the amount uh we'll leave it as eight for now and then play with that later the next thing we're going to do is for the time we're going to change this to 0.5 or the randomness we're going to change that to one now if you're wondering what I'm doing um basically these are just a bunch of settings to help me draw fire now the hard part is teaching this because a lot of this was just kind of guess and check um when I made to when I came to do this myself so um you're if you're looking to change this or make your own it's going to be really hard because you just need to kind of guess and check as well unless you're really smart and I don't know how to do that without guessing and checking so okay so let's um in the process material we make a new particle process material and let me just bring up my reference and we have quite a few things to change the first one is we're going to a mission shape and we're going to create it into your surface we're going to go to the direction right here we're going to change that to 25. and we're going to change this to 1 and this to zero so this is going to make it go upwards and the gravity we're going to change that to zero because we don't want it to go back down we just want it to they're all wood up essentially and then have it keep going up so for the initial velocity and for the angular velocity we're going to set the relax velocity Max to 7 and the velocity Max here to 70. and then for the angle let's close these for the angle we're going to change that to 360. 360. and for the scale I think the scale is something I did for the actual scale but let's not worry too much about that okay scale I added a curve so texture curve and in this curve we're going to click this and we're going to just add a point by dragging this down and I'm clicking I think we can or do I add here we go add point and we're just going to drag this up and we want it to go straight up about here and then back down to about 0.5 so it should be somewhat like that don't worry if the numbers aren't the exact that's the general idea so that's the curve let's close the scale now for the color the color is where we're going to use the fire truss I believe so here we can we should be able to just drag it in I think if we do that nope radiant [Music] ah here we go we drag that in there and then in the gradient you should be able to drag that in here as well there we go okay so that's the default fire color so yeah let me redo that so you can hopefully get that so for color wrap and initial ramp we're going to create a new gradient click it and then we say gradient and we're just going to drag our fire color into it you could alternatively I think just there's some things you could copy I'm not 100 sure but it's a lot easier to just do this so let's do that for both of them so fire here we go and now I think that's nope we're almost done now we go to animation and we're going to switch the max speed and offset Max I believe to one for both of them and that's it for the process material now for the draw pass we're going to I believe let me just double check so I don't say something wrong we have the quad mesh in our material we're going to create a new standard material 3D we're going to open it and we're going to go down to Albedo there's a few things we're going to change but Albedo is the first one and we just drag in the smoke for the texture and then we're going to go to vertex color and use on our as Albedo or Albedo however you want to say it we're going to go to shading and we're going to say unshaded and we're going to go to transparency and say depth free pass and then add and then we're going to go to billboard and say mode particle billboard now we have some particles coming up minimize everything and now we have our particles so this doesn't look like fire but what we can do now is we can go to the amount and increase it by a lot and now we'll have this so 20 000 is actually a lot what I used was about seven thousand I used this now we see that it's really big so what we can do is we can actually scale it down all right so after playing with it a bunch the best solution that I found unfortunately is just to just scale it down to 0.1 so it'll look a lot different from this but that's okay I'm also going to be using local coordinate so if it's not I don't think it matters actually I think local coordinate is something else so don't worry too much about that and the drawing pass let me go over it one more time the size of the actual thing I'm going to actually change that to let's try 0.3 okay that actually works a little better nice okay so we'll do 0.3 and then point one for the scale of the actual thing and I think that's it everything else should stay the same so for the pass one make sure we change that to 0.3 we can maybe even try point two oh yeah that's actually a lot better so let's try point two um you could even try point one I thought I tried that but it didn't seem to work okay well it seems to work now so I guess we'll do point one and now when I play and I put it in my scene we get this cool little fire effect which is awesome now let's stop the play and make sure you add the torch to your world we can add it here we can say um objects and then we'll add the torch here and then what I can do is not do that I can move the actual torch instead so let's move the torch here and let's put on the wall so let's bring it up a little bit a little small so let's scale it and which side is the wall mount I think it's 90 degrees so let's or 180 so it's 180 it put it on the wall right there let's put it up a little bit okay there we go so now we put it up there actually let's put it down a little bit let's put it right under that okay we'll put it yeah that looks good okay so let's put it there and now now we're going to work on environment or next coming up we're going to work on in on the environment stuff so let's get right into that as you already know we have already created a kind of environment mainly for the sky so first off let's save this as its own environment scene and so how you the way you can do that is by going to this arrow and saying uh save and it's a mine is already saved and but a thing should pop up and allow you to save it and I have mine right here so let's actually create a new folder for it and say folder uh not folder in Via little or mints let's put all our environments in there and where is it here we go so let's put our environment in there let's go in okay there we go and now what we can do is reset this and so now we have a really dark gloomy scene which is kind of doo doo but that's okay now what we're going to do is add a new environment and in here for the background will add a custom color it'll be black and now this scene looks like this but when I play what we get is pretty much a really dark scene now the reason there is light is because in my character I've added a omni light so add a node called omniola in fact actually let's just delete this no highlight let's keep it let's keep the characters on the light and let's play and we should get this so it's a really dark gloomy um scene and if you're wondering how to kind of get the scene a little better what we can do is just make this a little bigger we can reduce that a little bit and here the light is on top of the head if you want you can just move it around wherever you want this doesn't really help very much what I did was I just put on top of his head like that and if I play again sometimes it gets a little buggy now it looks like this now it's not shiny too much but you can still see the scene and there's our little light so there's our little torch however the torch isn't giving much so why don't we add in a light to it so if we actually search up the light we have a few different things we have directional light omni light and Spotlight now this is pretty good for what we want so let's try this let's increase this or let's take that rotate it we'll why don't we actually we'll use omnilite for this let's do omni light for the omnilite let's leave it like that let's play and that's pretty much all we should be a have to do and now we have a little light let's actually move it so that it's centered around the light the torch in the middle there we go and now when we play it's disappeared so let's replay it and if I move away there's my torch and it has light and everything so that's really cool and so you can duplicate them and add a bunch so let's actually do that real quick so what I can do is I can just let's turn on smart snap and control D and then I'll just move a few down and let's move this one over here and then add another one right here and then let's take the second torch and move that down a little bit in the first torch and move it down even more okay so let's play and now we'll have a bunch of torches in a row awesome so we have a cool little torch effect okay so for the environment what we can do is we can save this as the dungeon theme so let's save this in our environments and I believe that's kind of it one thing that I like that you can try is adding volumetric fog we can add that play and this is what we got so it's a pretty cool environment fog effect and it's really up to you if you want to increase the density and play around with it you can do whatever you would like but this is something I found really cool so that's it so I just um added a fog and I changed the light color to this it's just a little darker than what it usually is so now the final result looks like this so I just wanted to let you guys know in case that's something you wanted to do for yourself instead of volumetric fog I decided to use fog so that's it for the environment let's close this and for the player let's now add in our weapon so when we attack he is actually attacking using a weapon but he doesn't hold anything so it doesn't really look like he is so what we'll do is to his right hand slot we're going to add an area 2D or 3D sorry and then in here we're going to add two things a kill Vision shape and for the Collision shape it'll be look like it'll look like that we'll just make it like that and move it up a little bit and then let's add in the source so let's actually just search up sword and we have two different types we have we have a bunch of stuff we have a shield I guess sword shield that's not really what we want let's add in do we want this one or do we want this one what's the difference Actually I don't even pretty much the same one is just a bit more broken okay uh that's not what I meant to do okay let's use this one so for this we have to drag this into the area 2D we'll make it local and we're going to drag out the mesh because that's all we need so let's delete that and what we'll do is we'll just reset the transform for everything and now we have this but it's reversed so let's just flip it we'll flip it um 180 which is awesome so actually let's do this manually so 180. the z180 and then the rotation we'll move this up a little bit and the rotation for the X I actually want to change it to 90. nope the Y yeah there we go so now it looks like it's upwards okay and now it looks like it's holding it which is awesome so I believe let's let's do two things so first I want to add something to the attack State this will allow us to control the speed that the uh animation player goes at so in our attack State let's go to our scripts go to the attack State and in the physics process we're going to add this piece of code player.getnode.getanimation tree because remember animation is actually the playback not the animation tree so we have to get the animation tree we're going to say Advance Delta times one now this should actually make it really fast so let's see okay that's actually the default I think so let's uh increase that number play again and see what we get okay so that's really fast so now so now let's decrease it by 0.1 or 2.1 and now we should get a super slow attack okay that's our really slow attack very cool that's a really slow nice attack but there it is so there that's a really slow attack now in order to see if the area 3D is actually following it what we can do is we can actually go here and go to visible Collision shape and we can play and let's see if the Collision follows up okay it does awesome so now we see the Collision that follows the sword which is really cool because that's really that's actually really accurate right so now we can actually see all the collisions around us and let's turn that off because it kind of looks ugly and Okay so there's one thing I want to add in case you're not if you haven't used the K kit and you're using some other and uh thing I'm going to add a piece of line that's going to help you um figure out some things in terms of transformation this is what I use so self dot transform this is specifically for the um here actually let me just pull up my reference here so this is specifically for this guy this model so here we have the area 2D um this sword and I had to adjust it so that it fits the sword in game and obviously it doesn't look like it does but in game it does and for the area 3D I had to basically set its transform to constantly follow the sword so in order to find the sword what we had to do was printed the there were things that we had to do here so we have to print the uh get parent get parent find bones so we have to go to the skeleton and find this bone and print it and that will print us the number 58 because here each one of these has its own ID unique ID so it has a number right so each of these bones has a unique number and then so ignore this one we don't actually need that one and then here I would just say get the global position of where it is right of that bone which I think was the right hand yeah right arm I don't really remember I think it was right hand or right arm one of those two and I don't know a third joint that's the one and then I just set the transform of the area 3D to that so if you're having troubles um getting the area 3D to follow because you're using some other sort of thing this will help you a lot and in the future if you ever use something else um this will help you a lot okay ignore that then okay so if you're using the K kit we don't need this so let's actually remove this and we'll leave the script because it's uh we'll use it later so let's actually delete all these and save and that's it okay so um let's get into creating an AI the first thing we have to do is create a new node we're going to create a kinematic no not kinematic I keep forgetting that they change it we're going to create a character body 3D and here we're going to go to Collision shape where is it uh Collision Collision shape if I can spell it right there we go and we're just going to add a sphere and then what we're going to do is I'm going to be using the you know what let's actually do this let's um well first of all let's save this into here and we'll do um monsters we'll save in here we'll save it as Skelly and this guy will be the default skeleton so to do that what we can do is we can let's actually do this so we can go to player we can drag this in let's make it local and drag in the cake it and then minimize this and delete the rest we don't need this and this doesn't affect the player because we made it local okay so now we have our character with the animations with everything we need and we even have the okay what's perfect actually is let's actually increase this or bring that up a little bit and what's perfect about this is that the sword is there too so that's actually really nice let's minimize all this and we're going to be using the sword in a minute so um let's not worry too much about that okay let's minimize that and let's rename this to Skelly and we now need to add a few things so in order to for this to work we have to add um let me just get my reference we need to add a few areas where it will detect the player so the first area because this is a melee we need one we need one area that it will detect the player to walk towards unless of course you don't want it unless you want it to always be walking towards the player we want it to be conditional walk so we want it to have States essentially right so this will have States in theory but we'll use the script States so what we'll do is we'll have will have an idle State we'll have a move State and an attack state so those three states now those states that we do will not be script wise and then we'll it will not be animation shoe-wise we'll simplify this as simple as possible it's not going to be very complex but it's going to be a nice AI that that just chases the player that goes from idle it chases the player walks towards him and then attacks him and if he leaves the attack area it'll start chasing again and if it leaves the if the player moves the chase state or chase area it'll start to go into idle State again so we need to add two areas area 3DS and we need to duplicate this and we'll rename this one to attack player and then this one will be Chase player so let's add collisions to these duplicate this and I can just pop that in and let's create them as a sphere so this one will be the attack so we'll actually keep it around that big we'll move it up a little bit we'll take this one same thing sphere and then we'll make this one a lot bigger because this one is going to be the area where it chases the player okay so let's take these two and lock them and let's just make them invisible because we don't need to see them right now okay next up we have to add a script to this so let's build have a built-in script and let's do a template uh we'll do DEET node default we'll create and delete all these and then let's go to attack player and just connect everything so we're going to do the area entered no body entered sorry and then Chase player we're gonna do body entered and then attack player we'll do body exited and then Chase player I'm going to do body exited okay so we have Chase exit and end body a Chase player X enter and then vice versa for the attack okay so there's a few variables we're going to need in order to keep track of what's Happening so first of all we're going to add the speed and jump full okay we don't need jump velocity we just need speed so let's have its speed this will be the speed that the thing goes at and then these two variables will be will help us keep track of things so C player will happen if we can chase it okay so what we can do is say c layer equals true right now if he exits we can say C player equals false right so this will help us keep track of what's happening and then we can also do that for the attack right so we can say here we'll say it's true if we enter that area and then if it exits that area we'll say yeah false now in order to keep this super accurate Well what we'll do is or the exit will also add sorry attack is equal to True here and then attack is equal to false here but here we'll also say if it exits well most likely that means we're going to see players equal to true and if it enters we'll say C player is equal to false Okay so make sure you understand what's going on here essentially what we're doing is if we enter the area where we can attack I want to say okay we're going to attack the player but we're not going to chase him so this is actually Chase player should probably change it let me do that right now actually say Ctrl R say Chase player and replace them all there we go so replay if you do control R we've we can just replace everything easily so we have Trace player and attack player so if we are in the enter in the area of attack we don't have to attach Jason we only have to attack okay if we're in the if we enter the chase state it doesn't matter if we're in the attack state or not because at that point we're just going to chase either way and then if we exit the attack state or attack area we want to start chasing the player again and not attack him okay awesome now this is kind of important because now the problem is body entered can include the floor now we don't want it to chase the player if we're looking at the floor right we only want it to check if that body is the player so what we can do is say if body Dot name or what we can say actually is layer as oh no in body dot name this one's actually a little less bug prone especially in the future with things that we might want to add now however we have to make sure that it's cap case sensitive so we'll capitalize this and now we can do this for each of these so just copy it over to everything and just make sure we end it and everything properly and that's it so now we're checking for the player in the body.name okay all right next up we need to add a few things into our physics process so first of all let's add a few different things so let's take let's Auto load the mesh the um we'll just say mesh and for the node we'll say get this guy and it'll be K and make sure that we say get node properly oh my gosh well there we go okay so we get the character we Auto load the mesh we're going to add gravity and we're going to hold a direction globally there's a reason for that later on and then lastly um that's different and we'll also add Health why not we'll add that right now so we'll give the pla the Monster Health right now okay so let's add our physics process function so we'll say physics process and in here what we want to do is we want to first get access to our player so we'll say variable layer is equal to get node and then get it now how do we get it that's a great question so it depends on where our player is and where our monster is so generally in order to keep this like bug prone what I do is I'll add a 3D uh let's add a node a 3D node and let's duplicate this and what we'll do is we'll say player let's add this here so we can actually name it player and then we'll name this um let's actually rename this to characters and then this to monsters okay so here what we want to do is we want to take our monster and add it into this folder so we'll just pop it in and we'll put it there so there's our monster let's see if it's on the floor properly should be let's just drag them up a little bit okay so there's our skeleton now from here we want to be able to get the player so how can we do that well here we can just drag it which is nice but let's understand this so This dot dot dot slash means get get parent so we're going to go up one parent we're going to go up another parent Two Worlds and then we're going to go down to characters and then down to player right so that we get parent twice go to characters and then player okay let's just remove that and then add that so now we have access to our player now we want to see if player is valid so if player is valid what we'll do is we're gonna we're just gonna get the players the direction of the player we're gonna see where the direction is right so we want to find out where it is by just saying player.position minus our own position and normalize it and that'll give us the direction of the player now what we can say now is say if C player no chase player I changed it if Chase player is true what we can do is we can first we can move towards it by doing this by saying velocity.x and Dot Z is equal direction Etc et cetera so this is the pretty much the exact same thing for moving the player right and that's pretty much it now in order to make sure that this actually kind of works we can say if Direction then we can move if direction is not valid then we'll we'll actually move if it isn't like if we can't find the player or for some reason the player doesn't have a position proper or whatever then we won't move towards it but if it is then we will move towards it okay now we also want to check if we're attacking so it will say here if Chase player L if attack player so we'll say attack player player is true then we want to attack so to attack what we'll do is we'll just set our velocity to zero because we don't want to be moving as we're attacking so we'll set our velocity to zero and then what we can do is let's actually load one more thing that I didn't actually do in my reference we'll say on ready variable NM equals get node and we'll load our animation player so let's go here load the animation player and then here we can say if attack player is true we'll say lay the attack I think it's one H let me double check the we have to double check the weight spelled okay perfect and else I believe it's idle so let's say NM dot lay idle right so let's make sure it's spelled correctly okay just case Capital now let's also add this to here and say run now what's happening here so first of all we're checking to see if Chase player is true if it is we're going to check for the direction and then we're going to run towards it right so that's what this is now if if attack player is true right we're going to attack and set the velocity to zero now we also want to set the velocity to zero if we're idle okay now this is not the best attack State format because and there is actually a better way match might actually work a little better but I'm just gonna do it like this for now okay um but basically we have three different states we have run attack and idle and it's not the best way because this this only works because we have so few if we have more States and more attack patterns and stuff like that we don't want to do this because this will overwhelm us very quickly but for now this works fine um for the um Direction one other thing we can do is move the mesh towards our player by adding this and this is the exact same thing that we use for rotating the player however let me just make sure we switch the player mesh with mesh so replace all so this is the remember when we used the rotation for the player this is pretty much the same thing but we're going to rotate it towards the player Okay so direction.x okay so now let's actually also do this for the attack so let's go here and say that and here I actually also check for if Direction in the attack or the mesh rotation because sometimes it would error mainly when the player dies but that's okay so we'll leave if Direction mesh dot rotation okay and that should be it that should actually work oh we probably want to add gravity that'll probably be a good idea so we actually fall to the ground let's add gravity if not is floor velocity dot gravity and then um we also actually want to reset the direction every time we go through the physics process and I believe that is it no that's not it because we want to move and slide newest Freedom or something okay so moving slide will actually help us move okay so let's play and see what we get so all right there's our little monster over there let's see what happens if I get in range oh he's attacking and he's moving towards our Direction and if I get in range it'll start attacking us yeah okay so it works nicely so let's add a few things first of all we want to add health so we want to make sure that the health actually works so what we can do here is we can check for if the health is is less than or equal to zero so we can say if health is less than or equal to zero then we will yet knowing we don't have to get node we already loaded it we'll say animation dot play yeah I don't know if that's what it is I haven't seen it yet so let's go over here and look the feed okay there it is yeah feet so that's the defeat animation let's actually see what it looks like let's go to defeat and let's play it ah there he goes okay um now we play the defeat now we want to connect the animation finished and add it here so here what we'll do is we're going to play the death animation and then what we can say is we'll check to see if we play the death animation or not in death but defeat in this case and if we did then we'll just cue free after so that way we don't have to Q3 the moment he dies we'll play the animation and then we'll die okay this first of all he's not going to die because we haven't added a way for him to die so in our area 3D for our player let's go to the area 3D that we added for the sword now we have to connect a we have to connect a body entered here that's not where I wanted to add it okay hold on let's delete this go back to our node let's disconnect this and connect it on self that's where we want to do it we'll say if monster in body dot name then we'll say body DOT health minus equals five and now what we'll want to do is probably just add the word monster to the sky so we'll say monster Skelly and then we'll also do it here because it doesn't save automatically and then we can play and we should be able to kill him so let's uh go do that let's go kill him why is my guy not playing animations interesting I think I might have yeah there it is it's not active okay whoa what is happening oh I was messing around with the brawl animation let's delete that okay let's attack kill him and it's not working why is that okay let's go to our skeleton and print the health let's see what's happening let's debug this together a little bit we might have to just reload because we changed some things and it was kind of messing with the game so let's try one more time and hopefully this works so let's go to him attack oh yeah he should be dead Okay so yeah there we go so the reason why it's not playing I I kind of knew this would happen is because it's playing and then it's going into this and it's it's playing trying to play whatever is here right so it's trying to play this but it's also trying to play this because the health is low so what we have to do is we have to add an await function and say a weight dot anim animation finished and that's it so this will allow us to stop the code no not a stop but I'll wait until this animation is finished but fortunately enough for us it's it won't really matter once it is done because once it is done we're gonna keep free anyways so let's play and see what we get okay let's go to him and kill him come here skeleton die ah there we go and he died and that's it so let's take out that print function that we added so we don't spam our debugger okay now I think that is it for the um attack or the uh AI we're gonna add some more stuff later so to prep that what we'll do is we'll actually add the death function and then for the death function we're just going to pass for now we're going to add some inventories and weapon drops later so we're going to add that in and we'll do that here so definitely add that in and we'll get to it later once we do okay that's it okay let's get started into our inventory system so the first thing we're going to need to do is create a global script to actually be able to hold our inventory so let's create a new folder and call it global and in here we're going to have two things we're going to make well two scripts or so let's create a new script and call this um game and then let's open that duplicate it and call it in that'll be our inventory and wait for it to scan okay cool and now let's go to Project settings on the top left open this up go to auto load and let's load up our two scripts so let's add in game first and then add in inventory there we go let's close it and that's it well so that's it that's how you Auto load a script okay so now let's open these and start adding things to it okay so in our game what we'll have is I'm going to put these three things these aren't really related to the inventory but we're going to need them uh later on anyways so let's add them in there let's close everything all these scripts on the left so that we have a bit more organized thing and now let me just open up my reference okay let's open up the inventory and we're going to have a variable called items and we're going to have it as a dictionary now okay what is a dictionary so a dictionary is very similar to an array it's basically think of a think of a large train each train has carts in them and each cart has people in them or things so this is essentially a train so each we have in a dictionary we have something called keys and then we have the value of that key so essentially what it will look like is we'll have the name of a key so let's say um it doesn't have to be a string so we're gonna have yeah okay I'll give you an example so let's say uh name and then the name of that object will have it as a string so this will be um which probably look uh let's say staff okay so this is a key and this is the value so the value is a string called staff and the key is a string called name now the way we're going to do this the way we're going to organize this inventory well first of all these are the items that we have and that exist in the actual game so these aren't the items that we hold but the items that just exist period okay so the way we're going to organize this is we're going to organize it using numbers so each number will will signify a single item so first we'll start with zero so zero will be the first item that we have and that's a key so the key zero signifies one dictionary another dictionary inside so we have the Outsource side dictionary and then we have another dictionary inside that dictionary okay and now we can start storing information inside that so this is an item so this is One Singular item inside of a bunch of different items so the way we can show that is by having a comma and then we can just space and do one so we have one item here and another item here now if we go to the K kit skeletons let's look at the assets there should be it's an arrow yeah that's an arrow okay we'll use an arrow why not we'll say name Arrow and then yeah that's it for that now let's I'm going to add a few other things so I'm going to add description I'm going to say desk and this will be an empty string and then so make sure that we have commas on each line first of all and then the next line will have cost of the item so these are just some default things that I usually use in my games for information on items so you just want as much well not as much but you want all the information about your item in here so let's put type and lastly we have icon this one's pretty important and we will reload an R image but we don't have one right now so what we'll do is I'll just drag this in okay now let's fill this in a little bit so staff we say the type is a weapon the cost we can say 100 description this is uh stuff and then let's copy all this put it in here and then let's change it up so we'll say this is a green arrow this is a green arrow the cost we'll do 10 uh we can say misc for the type and then for the icon we'll leave it as that for now I will look for some I think I already linked it in the beginning but uh if you've already downloaded but I haven't downloaded it yet so I'll I will do that in the next part so let's finish setting up the inventory this one is a little easier because all we have to do is create an empty dictionary so what that looks like is just inventory that's it that is our MP inventory and so what we'll end up doing later on is if we want to add an item to our inventory all we have to do is refer to it and say okay let's take an item from our items and add it into our inventory so in fact what we can do is create a function for this so let's do that let's create a function that says that is add item and then we'll say variable has item equals false ah hold it on I forgot count okay count no that's in the inventory okay count we don't need it here actually because okay so in our inventory the inventory structure will look like this sorry about that so it'll be all this but with the whoops with the count so in here we will also have a counter to see how many of this item we have so that's how our game is going to work so don't worry about this I'm going to delete this but just keep in mind that we will have the E count in our inventories so here in our when we add a item we want to see if we have that item already so the way we can do that is by having a variable called has item and then what we'll do is we'll for Loop through our inventory so we'll say 4i in inventory so it'll just for Loop through the inventory with each key and then if I if I check the let me add a few spaces here if I say if inventory I at name is equal to the item name then that means we already have it now where is the item name coming from well we have to actually pass that through the add item so now we can add items using a specific name of something so I can add green arrow for example right and then what we can do is check if we already have a green arrow in our in our inventory now if we do this is actually pretty easy what we can do is just say inventory at I at count plus equals one and that's it because it should already be loaded and count would be like let's say one we'll just add one to it instead of adding another one into it and then we'll say has item is true now the reason we do that is because now outside of that for Loop we will check to see if ha if has item is false that means we don't have the item in our inventory now if we don't we what we want to do is first we want to get access to the item that we're that we're adding so we have to get it inside our items dictionary so first we'll follow you through the items and we'll find the item that we are looking for and that's easy it's the same thing as this but in items so we'll say if items at I add to the name is equal to the item name then we found our item that we need Okay so so all we have to do is copy that over so we're going to create so unfortunately Godot is a little hard we're not good though dictionaries in general are they are a bit tricky to add to so in order to add to a dictionary we can't just say plus equals we have to copy it over and then add to it so in order to add to it we have to basically set it equal to it so the way this the way what this looks like is first of all we're going to say temp items equals items so in the items let's say I want to add staff right let's say I want to add staff to our inventory and we don't have it so we're here right so we add it here but to do that we need to add the count to it so to add to the temporary dictionary we're just going to say we're going to say temp dick count plus equals one and this adds to our dictionary so this is as if I'm the coder I'm the pro on the computer I'm gonna do this I'm going to say okay count plus one or is one okay so that's how we add to a dictionary so it's not very intuitive right so we set it equal to one okay so now what we do is we say inventory at inventory size equals to Temp dictionary so this Advantage essentially allows us to add it at the end of our dictionary so if our inventory has things in it already let's say it has one object it'll add it or is uh at Key zero it'll add it at Point at Key one okay and that's it so um that's how we add to our items so now what we can do is let's create a ready function to test this out a little bit so we can say ready oh what did I do here um control Z items okay um spacebar here function ready and we'll say add item staff and then we'll print the inventory and then we'll also print it before we added it just to see what we have Okay so let's print it and see what we get or play and see what we got okay so here we go so here we've printed the inventory before so we have nothing in there and then after we added the staff we've added in our item and see here we can see um zero name staff description cost type icon and the count and that's awesome so let's try adding this twice let's see what happens it should do the same thing but it'll have count two there we go it works it works awesome perfectly fine okay so now that that's tested and done um I will lastly actually let's uh no actually did I add it here yeah I know I did okay so um that's it for the inventory I'm going to find some icons import them and if I didn't already link it um I will make sure to link them okay okay next up we're going to get into the UI of our inventory so the UI is going to be in a 2d scene so it's going to be on top of our 3D but it's going to be 2D so the way we do this is let's create a canvas layer so this will essentially be on top of our screen and it'll just be a simple 2D canvas layer scene that we can add to our game so I also added an inventory folder um with the icons that I've imported so I'll show you the icons I actually need to fix them because these are going to be the icons we use so probably use something like the staff and whatever but one of the problems is that it is in a big like big thing like this and I need to disconnect them so I'll probably do that if you want to download everything um the way I do it I'll leave everything I'll hopefully leave everything you need in a Google Docs folder at the end of the course and there'll be a GitHub link that you can probably download from so either you can do it yourself and and put all of these in its own file or just download it from what I do so here let's rename this to UI let's save it and we probably want to rename it actually to UI I just reflexively saved it and now we're going to create the UI for this so the UI for a inventory generally speaking it it kind of depends on what you have and what you want but we'll make it like very simple so I'm going to have a panel and this is going to be our background so it's actually turn on the grid so the grid is this guy and this is smart snap so we're just going to turn on the grid so we can see a little better so let's just do this and create a UI for it so I'm just going to create it so that it's in the boxes here and that's it that's going to be our background for our inventory so let's actually um take this and what we'll do is we're going to lock this and we'll name it BG and then we're actually going to add a node 2D doesn't really matter actually we can just do controller it doesn't really matter and then this is going to contain our inventory so let's rename this to inventory and then let's also add an animation player that's an animation tree don't want to do that I want an animation player there we go and then we're going to have in here in our inventory we're going to have a grid container that's going to hold our slots for our inventory and then we're going to have a button for our close button um you know what yeah sure we'll we'll implement it I'll show you how to implement that um so let's rename this to close let's rename this to in the container and then we're also going to have a label which is going to be our title title and then let's go to the where is it theme overrides on the bottom I'm going to go to font size and just increase it and let's actually write something so inventory as we can see that's really big so let's make it a lot smaller and just move that in the middle and maybe let's do 80 that sounds good okay nice that's a little big let's do 70. okay there we go so let's actually drag this out over here like this and then what we can do watch this magic that Godot will do for us we'll say horizontal and Center we'll Center everything and we'll also turn on auto wrap um the reason why I like to turn on auto wrap for everything is usually this I feel like this would rarely happen and it's more common in Android but the reason why this is good is because okay if I have a bunch of words it'll automatically put it to the next line instead of going that way to the right so if your screen resizes on a phone let's say you have a computer screen and then your phone resizes it instead of the words going off the screen it'll smart snap it and put it where it thinks it should go kind of right so it'll go to the next line so yeah so auto wrap is really useful okay next up we're going to go to our UI let's add a script and a default script awesome and then in here we're going to add a signal from here pressed here we go we now have the Press signal we'll delete that and lastly we're going to actually have our animation player work so let's add two different animations so we'll have trans in I'll say Trends in like this and then Brands ouch and then from there we just double check a reference we're going to rename the animation player anime and now for the what we'll do is in the transition out what we can do is say from here we're going to take our inventory we're going to go to our layout transform position and we're going to key that and then we're going to key that first position and now what we want it to do is slowly transition into a position where it is let's say 3 000 pixels away okay that's kind of far let's say 1000 that's fine actually we'll do six 50. we want a nice number okay so now it'll look like this so you can get it to transition out however you want but I'm just going to get it to go down now transition in what we'll do is we'll go from the top to the bottom so we'll say negative 350 650. and then we will go to one second we'll reset this and key that okay so now it'll look like this and then our transition out will look like this so it goes in order okay so in our UI what we'll do we're going to do two things we're going to firstly we're going to say let's actually load our animation tree so that's our animation so we'll say NM equals get node anim there we go and now what we can do in here on press closed we can say what is that I have to say variable that would probably be a good idea right in here it will say NM dot play trans out now what's cool about this is we can actually add another function called input yeah and then say okay so we're gonna have to actually add this we are going to say if event is action press inventory then we will play the animation Trends in but um we have to add this so we have to actually add this key because it doesn't exist so let's go to Project settings and add it to our input map let's add it and let's create it as e H you could do I as well if you want but I'm going to do e for now okay so let's test that and see what we got so there's only one way to transition in and out right now so let's see if those two work hello idle actually end up in front of us actually it won't end up anywhere because I haven't even added it to the scene so let's actually go back to our world first of all let's go to our player let's add in here hopefully that should work uh it didn't add I'm gonna have to okay there we go okay um what I'm gonna do actually is in our animation uh let's go to reset and have this like that and let's have it at negative 950. so that'll be our default reset and it'll always reset on uh screenplay so every time I launch the game it'll reset to this so we used to launch the game wait for it to load and I press e and our inventory pops up and that's it now there's a few problems obviously I can't click the button because my mouse is stuck so uh we have to do first here when I click the inventory I have to make sure that my mouse mode is visible so let's do that now another thing we want to do is we should probably want to pause the tree so let's actually do that as well let's go here say get tree dot pause is true now we should be able to transition this in have our Mouse and then unpause now we can't unpause because we have or we should be able to unpause so let's actually make this false now there is a problem this is a very very common problem I try to point out every video I make not every video but it's really common whenever you pause a scene you have to make sure if you have a UI you take the process function or the process mode and set it to always or whatever works IO I usually do always because always is a good way to make sure it always works so let's play and see what we get so we're in our game if it loads yeah the game is loading all slower now okay so we are in our game we press e and our game pause so I can no longer move and I can click the close button and we're back in and it lags quite a bit but that's okay but our Mouse needs to go back in so what we can do is say I think my computer is just being a little laggy right now it's not the game hopefully okay and that should work I'm not going to test it actually uh because it's my computer is being a little slow poopy right now so um I'm going to close that and you're just gonna have to trust me it works or you're gonna have to test it yourself so that is it we'll add a few things on the next part but for now this is how we do our inventory UI okay so the first thing we're going to do in our inventory is we have to explore the concepts of how we're actually going to build this and step by step we're going to build it from the ground up so so far we have our inventory as a script and we have it all in variables and this technically works right and that's that's it our inventory is technically speaking done right we even have a function where we can add an item however the main problem comes from interacting with our inventory and the UI of our inventory now this is where most people struggle the concept of an inventory system is actually not very difficult it is the concept of interacting with that inventory through the game that is where most people struggle so we're going to build this from the ground up one step at a time so the first thing we're going to do is we're going to go into our inventory container I'm going to drag this down to the bottom and let's move this over here yes and so the first thing we're going to do is actually fill our inventory with slots so obviously as hopefully you might know most inventories have slots in them right so we have a slot uh let's say 30 slots or 28 slots and each slot contains an item so let's do that so let's go into our inventory or actually we'll just make it from here so let me just pull up my reference so the first thing we're going to do is make the slot now the way you design the slot doesn't really matter okay so I'll I'll do how I you might do it or how I would usually do it which is I will have a panel or some sort of background and that will be the first node that will be the parent node and then I'll have a Sprite and then I will have a label and this label is actually going to be our count label this is usually exclusive to whether or not you actually have uh stacking in your game but it depends on what you want so again the structure of your slot doesn't really matter it just depends on how you want it and how you want your sauce to be so let's save this a slot scene and our inventory so let's save it and let's now rename this to slot and add a script now this is where the magic happens so this is where we'll be adding everything that we need to interact with a slot so the first thing we're going to do is we're going to create a bunch of variables that are going to help us interact with this now let me I'm just going to copy paste it and I'll explain each one as we go along so first we have all the these things so these are basically going to allow us to contain an item inside the slot it's going to be a local slot variable almost okay now the item name is just an item name description cost count type right so these are all the things that we actually described in our inventory right so everything will have every item will have these things including that we put out over here when we add it into our inventory right so in our plot we also have has item is equal to false now this is just going to be a Boolean that allows us to check if our slot has a item and we'll explore why we do that later and we also have a Boolean that says Mouse entered now the reason we have this is actually because we're going to not yet actually but we're going to be checking if so hopefully we already know this but I'll explain this concept anyways most so in our node system if I uh show everything so in our 2D canvas items uh usually it's 2D we have 2D node 2D and control so let's look at control nodes and scroll down a little bit here we have all these children as the the control is apparent of all these children right so we have panel a Tabor Etc right now what does that actually mean in good dough when something is apparent of something the child will usually inherit all the properties of that parent so the parent which is the control node is a parent of the slot of a panel sorry so that means we have the signals here on the right that are ingrained from from control so we can see it has says control now this is actually really useful because we now have Focus entered we have GUI input and we have Mouse entered and mouse exited now this is actually really useful because now we can just connect this and we also can connect the mouse exited and in these we can now say mouse if Mouse exited we'll say mouse entered is equal to false and if Mouse uh entered we can say true now for the mouse entered we only have to make sure it's true if we even have an item so we can actually check if has item is true uh we can do that or you could have just said without the true but I I always like to have the true because it kind of it's one of my habits uh mainly just so I can understand when I read it and know if I'm checking for it to be true or false okay the next thing we're going to do is we want to only show the Sprite so let's actually rename this to icon so this will be our item icon okay so in our item icon will only show it if we actually have an item so what we can do is say if has item is true then we can say get the item icon and uh show it right whoops and if not then then we'll say icon dot hide okay now we'll also do this for the count so we'll we won't show the count unless has item is true okay now we can do the same thing here and hide it if as item is false and that is it now if we do have item what we'll do is we'll update the count every millisecond so here we'll just say we'll actually remove that I'll say count here we go text is equal to string item count now the reason we have string here is because item count is a integer okay so an integer is a number right even if we had float so if it was like this that's also a flow now this is a problem because text is a string right so here in our scene here this is a string right so even though I type 0 that's still a string it's technically like this right so we have to convert it to a um what do you what you call it string right so this will allow us to convert this integer into a string right and now we can now actually check for input so we could do there is a signal here that says GUI input I don't like it it's a little limited so I tend to just use the input event now the reason you could try to make this work without all this and using using GUI input but honestly I I think this is a little faster and a bit more it makes a bit more sense so where's the end done let's pass for now if you can hear the sirens outside but there's Sirens right outside my door okay so now what we can do is check for left click now we have to actually add this because we haven't added I don't believe so let's go to our project settings go to input map and add left click and down in left click we will add the mouse button left Mouse button is this one I think it is yeah so we'll add that and now when we left click on a thing we should actually be able to do something so let's print something for now so we'll say uh let's print the item name item name and then let's actually make this work so let's go into our input or our UI for our inventory now you might be wondering okay how do I fill this in well do I just drag it in like this and then duplicate it or duplicate it Munch and now we have this well yes and no so okay first of all let's actually change the inventory container to make sure that everything gets sized properly so let me just find my reference here um for the whoops no we have to do it in these slots so in our slot what we'll do is we'll go to layout and we'll go to custom minimum size let me check what I have as the minimum size I think it's 64. yeah usually 64 by 64 is the minimum size so we'll move this down a little bit and in our UI we now have this so in our inventory container we'll actually change the columns to six and now we'll have a proper grid and now what we can also do if you'd like we can go to theme overrides constants and separate everything manually so we can do five and five or we can do 10 and 10. so now we can separate each of these slots as much as we'd like okay now let's actually fill our inventory the proper way and the way that most people do it okay because manually doing this doesn't really work very well so what we'll do is we'll delete all these and we'll add a script to it called inventory container and what we'll do is we're going to make a function called fill inventory slots now this inventory slots will allow us to up it'll do a few things first of all it'll up it'll fill our Container full of slots and it'll update our slots with the proper item that is in every slot so we have to do that okay so the first thing we have to do is we have to make two variables one where we pre-load the the slots let's actually rename this to slot so let's pre-load our slot that we just made hopefully that's the right nope it wasn't the right path and then we're going to also create an inventory size now this is going to be whatever you want I just did 24 because I would like 24 slots now the the way I usually calculate this is if I have six columns 6 times 4 is 4 rows so we'll have six columns and four rows okay so 24 is a good number or six times five is thirty so I try to go by a whole number so that way it is organized and we don't have like five slots in one row and then two slots in another row it looks kind of weird right so we try to organize it quite nicely okay so the first thing we're going to do is we're going to for Loop through our inventory size so we're going to say for Loop and in inverse size okay now in each eye we now fill one slot or we we add a slot so I mixed up a little bit sorry we have to actually add every all these slots in our ready function not our fill inventory so let's actually add our ready inventory or ready function and for here let's pass for now and here we can actually just copy this and do that instead now this is a lot easier all we have to do is say a variable item temp or we'll say slot temp and then slot instantiate and then add the child a slot temp and this will do it 24 times okay and then we will also call this function right after so this will actually allow us to fill these slots with the information and then this will allow us to add these slots sorry about that mix up I just was mixing up my words a little bit so now when I play I actually will just have my inventory slots now when I click on a slot it should print the item name now it didn't print anything because I don't have anything in the item name so let's actually go over here and say default and let's replay the game and see what we should get now if I enter a slot it should print a bunch of times now this is a problem because what's happening is that this is going to happen a bunch of times and I haven't even checked for Mouse entered now if you you don't have to count but I'm going to tell you this printed default 24 times why because what happened is it didn't check for the mouse entered it just printed 24 times because we have 24 slots and we we didn't check for if the mouse is on a specific slot so each of these slots have its own custom unique ID to control and so Mouse entered will work really nicely now however input will not work very nicely and because each slot so if I have two slots open and I'm checking for both of them then it's not going to work because yeah like it's just going to print 24 times hopefully you understand why this is happening and now what we can do is in our slot we'll just say if Mouse entered then we'll print the item in so let's replay and hopefully it should only print one time so let's go to our inventory play or click oh why is it not working let's double check okay I think what we actually need to do you might need to change some settings let me double check in our UI selection exchange okay let's replay and hopefully this should work um okay let's debug this and let's print Mouse enter and see what we have on my Center to messenger okay let's see what we get oh yeah here we go because has item is never true so let's actually let's make this true no matter what let's delete that okay let's play and now it should only print there we go so now we print the one that we actually printed so let's uh change everything back if that should be let's remove this so as you can see what what my little buddy happened is on Mouse entered it didn't trigger because we're also checking for if has item which is actually good that means it won't we won't be able to do anything in our inventory if I I don't even have an item so it's not even registering that my mouse has entered because there's no well it did register but there's no item in here to have so there's nothing there to do I can't click anything so that's good so um that's it let me in the next part we are going to actually fill our slots full of information so all right so I continuing on from our fail slot inventory right fail inventory slots now we're going to actually fill everything with information okay so we have to think about this in two parts so there's two things we have to do the first is we actually have to clear everything now why are we doing this why are we clearing what even is clearing so clearing is we're going to set all the information like this we have to take all the information in each slot and reset it to zero essentially now why are we doing this well because if I only filled all the informations with slots or all these slots with information I wouldn't be able to distinguish or be able to separate which ones have information which ones don't now the best way to do this is just to clear everything right it's the easiest way it's not the best way but it's the easiest so what we'll do here is we'll clear all Slots of all information we'll reset everything and the nice part about this is that now we can fill all these slots with inventory info now here we're actually going to for Loop i n not inventory size but in if Dot inventory okay because we only need to fill the slots with the information of how many items we have from the inventory so here we'll just pass for now so we don't get an uh error and in here now what we can do is we can say get child dot i is equal to nothing dot item name so we can do this for each information things we have so let's copy all these actually and what we'll do is we'll go back to our let's just say in our slot and then in our inventory container we can actually copy paste this let's do that and what we can do is we can say get child.i and copy it into each variable here like this and now we've reset every single thing that we need okay um let me just double check some things we also need to say has item is false so we're going to also say has item is false for each of these and that's it now uh let's delete that and now we actually fill it so here we've reset every slot to have no information in them now here we want to actually fill each slot with the information from our inventory okay okay so the way we can do that is very similarly we'll we'll just take all these and copy paste it and we'll say has get child.i or get child I dot get item name is equal to not nothing but in fact we actually want to get our inventory I Dot dot so we want to get the name of our I right so this refers to the like let's say zero let's say I have uh in our inventory here it is if I have an item here let's actually do that let's add in an item manually so we'll say zero and then preload icon and then here we'll say count is one let's say two actually and then I'm gonna get an error here because I didn't add a comma okay so now I have an item now inventory container we're going to get access to it by saying because I starts at zero so it'll get child zero I set the item name to inventory 0 at name so it'll go inventory 0 which is right here and then we'll we'll go here and get the name which is Green Arrow okay now we want to do this for everything so we'll we'll actually just copy paste this and I want you to refill everything okay now fill everything that you think is proper here right so hopefully you've paused and unpaused now all we have to do is just copy these from description you have to get the cost right here good luckily it's all in order except for the type I think type is over here and this is count and that is it so we also have icon but we'll do something different for that okay now we also have to say has item is row okay and lastly we have to now load the icon so let's say get child I Dot icon no we're going to say get node icon okay and then we're going to say dot texture is equal to whatever we want now the texture is actually going to be the icon texture so we can say we can say it like this the inventory dot I uh inventory icon so here what we're doing is we're essentially from our UI from our inventory container if we have some slots in there we're going to go into our first child let's say our first slot and we're going to go into that slot right so here we're going to get the icon and we're going to fill the texture so here's our texture let's say let's actually put a default texture for now okay that'll be our texture let's make it a little smaller we're gonna have to resize it once we get proper items in but this will be our thing so let's hide that and let's actually reset this so I know it works okay let's play into what we get so um let's actually make sure we've called this okay so here we have it in the ready function another place I actually call this isn't just the ready because the ready function calls this once in an entire game right or every time the scene is loaded now I don't want that I want it to actually also be called if I ever click inventory if I ever open my inventory I should also update my inventory so let's actually do this and say we'll get the node and fill the inventory okay so let's play and let's press e and there we go there's our there's our slot item and now I can click it and it'll print Green Arrow awesome we now have access to our slot and we can interact with it using input okay let's edit a few things in our inventory input here because there's a few problems when I in my game if I click e twice it just keeps putting it back in now I want it to if it's here I want to be able to press e and have it leave our screen okay so what we can do is here what we'll say the way I do there's a lot of ways to do this really you can check for pause tree you can do whatever the way I do this it's really simple I just check for the offset so I'm going to say if the offset of not going to say self here I'm going to say the inventory if the inventory dot is it offset though for this let's check let's go to layout and no it is not offsite its position okay so we're going to check for the position.y now if the position dot Y is equal to negative 5 650 that means it's outside of our screen and it's above us okay now if it's zero like that that means we want to get it off our screen so we can also check for it we can say LF we'll say let's actually just do this and we'll copy this and go here L and copy now if the inventory position is zero what we'll do is we'll say Okay paused is equal to false and then here also transition out and then Mouse mode will be captured okay there's one more thing we have to check for I think let me just double check here yeah so when we transition out remember that we leave it at 650. so here what we can say is let's actually put this in Brackets and then we can also add or let's copy this hopefully this will work and I don't have to add an alif in my reference I add an LF so I don't but I don't think I have to I think I can just do this okay so let's play and try it so let's press e there we go and when I press e again it disappears and if I press e now the beauty of this the reason why this is actually really cool and the reason why I check for this is because if you were to check for something else and you press e now I want you to test this I want you to press e and start spamming e you can't hear me but I'm spamming e now the beauty of this is that it doesn't cut the screen it doesn't cut the inventory halfway through if the inventory is going down and you press e again it doesn't reset the animation usually when you play an animation you can interrupt that animation by playing it again now we don't want that to happen but that won't happen because here we're setting for we're checking for the exact position right so here what's happening is if I press e it won't play the next animation until I get to position zero or position any of these checks that I'm I'm checking for right so it won't do that it simply won't so that's the beauty of this code okay all right I think that is it for this part I think we have everything working let me just double check okay everything's working so let's continue on our slot I want to actually be able to interact with our slot and do things with it so the first thing we have to do is we have to create a a UI that I can interact with the information or the actual item now we have this slot we have the interaction with the slots now we don't have anything to interact with the slot information so let's make that so let's create a new node let's actually go to the skeleton and close that and the player we don't need those open right now let's create a canvas layer so canvas layer we'll rename this to item info let me just double check that's what I called it yeah item info and then enter item info we're going to have a bunch of things so what are those things well first of all let's go to 2D scene because that's what we need let's save this as item info let's put it here and let's add our panel I'm going to have a background for a panel and we're going to basically have this as our reference of items so we're going to put all the information item name icon all those things okay so in our this will rename this to background let's also add an animation player we'll rename this to anim we'll also add a label we'll duplicate it because we're going to have one label for the title and then one label for the uh description Amazon order so for the label this will be our description and this will be our um title yeah that's what I call it so let's actually put this on the top and let's put a default thing so let's say item name and let's resize everything to how we want it so let's go to the description and say this this is a uh description [Music] of our item now we have to Let's yeah let's change everything so let's Center everything and then let's also put auto wrap on Word Smart now let's resize this put it put it right here why because we're actually also going to have an icon we'll put that right here and let's resize it to be proper so let's actually go to the transform uh transform here we go and we'll set it to 0.6 for both of them or not points six yeah there we go and we'll Center that hopefully somewhere and drag this down let's actually drag everything down a little bit let's take our item name and drag this here we'll Center everything put everything on Word Smart and then we'll also go to theme override font no font size and then I'll increase it a little bit okay and you can kind of mess around with this you can even add your own theme I would definitely recommend that especially if you're making your own game the default Godot theme is not the best it's pretty they actually improved it in good 04 but uh it's just a default font right so I would suggest going online and looking for a better font that you like and that matches your game okay the description um let's resize that like this looks fine and we are going to have a few items or buttons to actually interact with this so let's add a few buttons so let's add a button let's add two buttons let's actually uh leave one we'll take one for now and then just duplicate it here so it's easier to drag actually Let's Not Duplicate it yet what I'll do is I'll resize it I'll say close and then let's resize it to how we want let's put it like that and then I'll duplicate it so that way they both have the same size okay we'll say this is use so let's rename them as well so this is use and this is close and I think that is it for now that is it awesome so now let's also make the animation player work so in our animation We'll add a few things so we'll go here and we'll say trans in Trad trans ouch we'll transition in and transition out so from transition out it's actually really easy we have here so we can go to transform we'll say the offset is here and then off we want to say the Y is 650 I guess yeah that looks nice okay let's key that and so now we have transition out and then again transition in actually what I do I don't do this actually we'll do what I do so let's actually reset this to 0.1 and what I do is I just set the position right away I don't and I don't animate this usually because the transition in and out of the item name I want it to be instant I don't want it to smooth in and out because it's not something that needs animation when I click an item I want to be able to navigate quickly right so in our transition n will actually reset this to zero and key that key please there we go we'll go to our reset and our default will be 650. so our reset will be this and I'll key this so this will be our default and then if I transition in it should pop in like this the time of the animation doesn't really matter but yeah I'll just set it to 0.1 and then transition out it'll put it outside the screen okay so back to our slot here now what we can do is or should do is get access to the item info so let's decide where to put this let's put this inside of our inventory so let's go here and item info so we'll drag this in to our Here and Now from our slot we need to be able to get access to this so where is our slot well first of all we don't even have a slot so it's actually added in it'll make it a little easier to get access to it so for my slot script we can actually just do this item info now let's actually just load uh should I I don't know if it'll error let's try it let's try seeing if we can load it let's go to the top say on ready there item info is equal to this and let's pass and let's play and let's see what we get okay I don't think it aired so let's actually try to actually animate it now if I click so let's say item info Dot uh yet node NM dot play Trans in okay so let's try that and see what happens so now when I click on the slot it should transition in and I spelled it wrong so let's make sure I don't capitalize that and let's try again and there we go there's our our slot so the first thing we have to do or realize is that the layer is on the same layer so let's actually make it in the front and now we have our layer in the front so now we have our item info here okay um yeah that's it so we now have access to our item info and next part in the next part will actually fill in the item info with our information from the slot as well so for now uh I want you to just adjust everything how you'd like it add backgrounds change the backgrounds all that stuff so yeah okay welcome back so let's get right into the filling our slot information from our slot so as you remember we check for the left click we check if our Mouse is in that slot and we can now play transition in now I want to actually feel the information with all the information that we need so from our slot all we need to do it's very similar to feeling from our inventory where is it from okay first of all let's delete this slot from here it's very similar to this filling into our actual item info so from our slot we want to get our item info dot item name and just fill in item name now this is going to be a bit confusing because it has the same name but this item name will be from here and we're going to get the item info name of here of the item info if that hopefully that makes sense because if it doesn't um it's going to get a bit confusing you should I should have probably named it something else but um it's okay I think it's fine so let's duplicate this a few times and what we'll do is we'll just copy paste this for everything we'll go item cost item cost item count item count and we also have item type copy paste that one more time we have item type awesome and lastly we also we will want to oh yeah we also want to set the texture so we say item dot info dot get node uh let's say icon and then we have to actually make sure that we go into our item info oh it's already named icon I forgot I did that nah I'm so smart we say item info dot get icon and we'll fill it in with what we currently have for this icon so we'll say item icon dot texture hopefully I think that yeah that's what I have and why is it doing this oh yeah we don't want to set texture and there we go okay now what we want to do what I want to do is I want to make the process of the inventory false so here we're going to get the no we're going to get parent from our uh slot we're going to get parent to from here to here to here so we're going to go here and we're going to disable the inventory so we're going to disable the process of the actual inventory now the reason we're doing this is because actually let's yeah we're gonna disable the inventory here because what's happening is if I go here let's actually disable it manually and see what happens so if I press e it'll pop up but if I press anything nothing's happening so because and it was kind of buggy and the reason that happens is because we've disabled it manually so here you can see that we can't even interact with any of them so let's actually reset this now the reason I want to do this is because okay let's play and here we go here's our item info and we already got bugs very cool invalid set index item name let's go here item name why is that happening item info dot item name invalid set interacts with value type strength so on base canvas item IC okay so we might have to get the node itself so item info here oh we didn't even add a script that's probably why okay so enter item info we're going to want to add a script to that and we're gonna just copy paste this sorry about that we have item type we have a bunch of stuff very cool okay so you can just copy paste this part right here should be the exact same okay now let's play again and try that hopefully we don't get an error okay so if I click this nothing's going to happen so let's find out why all right we're going to have to debug a few things already okay let's take all this out and see what happens okay oh no I remember why okay so let's reset that okay so what happened is I actually this actually did work but it disabled it right away so the reason why that happened is because now in here we have to actually make this process always so that's okay again let's go again let's click it in slot and this pops up now the reason I disable this is because if I have other item slots here I can click them and this will pop up and remove it and the problem with that is that if my mouse is over here or actually let's say right here you can see my mouse and if I click or even if my close button was over here and I click on top of it and the slot is behind my mouse it'll click both of them and it it won't be able to distinguish which one I'm clicking on so as a solution I just disable the actual inventory see here I can't even click the button I can hover it but I can't click it it doesn't do anything well obviously there's no way to get back so let's actually just close the game and keep going so from our slots we now have filled the item info with everything we need that's actually I didn't even look let's check that to see if it actually works so here we should have item name um it's weird actually it should be green arrow should it not let's um item name see what we get I believe it should be green arrow so I don't know why it's not working oh no I know why it's not working because we're not doing anything with that information haha okay we're gonna want to update the information so um just one second okay um what we want to do here is we want to create a function where we update the information so we can say update info and we'll just add get node title dot text is equal to item name and then we'll say the description is going to be equal to the item description plus the cost now this is new line so we'll just go to the next line and then add the cost that's how I usually add it and here now what we can do is we can actually call this every time I click on a slot so like all I have to do is say item info dot uh update info let me just double check that's how I do it in my yeah that's how I do it in my reference okay awesome now when I play and I click the slot item it should pop up with the information unless I get a cool error okay what's the error invalid okay you know what let's just convert everything to a string so I don't get any errors okay invalid set with base oh that's why I spelled this wrong that's not why okay so in our item info here we have description like this and I didn't get the node properly okay okay let's try one more time there we go now we have green arrow this is a green arrow with cost 10 and this is the icon that we use for that green arrow so let's close this and let's add in a signal for the close so let's actually go to our closed and press and let's also add a signal from our use and that's it so let's add these two now that's it for now so let's also add something that will actually have used for later so we're going to check for the item type if the item type is equal to a misc we're actually going to take the use and update it to use now if I have something else that I want to equip I'm actually going to say else I could you could do L if but I'm just going to do else because I only have two types in my game so I'm going to say get item uh get node use and say dot text is equal to equip okay and now I can have in my inventory if this is a misc it'll say use now if it's something else I'll just say right hand I'll play the game and pop this up now it'll say equip instead okay so now we can change the text depending on what type it is so I'll change this back to a misc or whatever you want maybe it's a back item or whatever okay so it's really up to you and now let's go back to our item info and we're going to do this next okay all right welcome back so the next thing we're going to do is realize that I cheated a little bit and I I actually have a pack from the same artist with um different items but um I think I think they have it yeah so I have more but you should be able to get these same items here and now I'm going to actually adjust everything to fit these icons so for the item info I'm just going to put on a random one and I'm going to adjust it properly so that it actually has the proper scale so I want it to be that big okay and now for the slot I'm also going to do that for here so I'm going to add in a slot item and I'm going to adjust it so that it fits the actual slot and then let's also adjust the count and move that up here let's actually move it right there and what we'll do is I'll actually we'll make the font a little smaller so we'll say maybe 15 actually maybe 16 oh no that's the same size let's do 10. nope 12. let's do 12. then I'll adjust it right there and I wanted to start reading from the right so let's actually adjust the vertical to the uh yeah let's do Center and right so that way it'll start reading from the right to left okay now I can adjust it here and the more numbers I have it'll read to the left and then auto wrap will put on smart and that's it for these count so now the count will look a lot better so let's say let's just put it at like 100 usually most games will cap their account at 100 so that's good and now lastly let's go to our script go to our inventory and for this let's add a staff so let's go here and look for a staff it's hard to see but I think let's like drag it out that one is not really a staff I don't know if there is a staff well that one looks like a staff okay we'll use that one leaves item iron weapon 28 and then for the Green Arrow I don't think there are green arrows obviously so we'll use what is this that looks like an arrow kind of not really yeah you'll probably want to add your own proper icons but for a placeholder just so you can understand the difference in the game we'll just put this for now so we have 27 28 so we have two different icons now they actually look proper and let's actually delete this because that item doesn't technically exist anymore and let's now go into our UI item information and let's actually make this stuff work okay so the first thing we want to do is let's let's load our animation so let's say unready and um I will say anim dot equals get node anim and now what I can do is on close I can just say anim dot play trans out and then what I can also can I should do uh I'm gonna have to say variable annum I should do is I have to set the process function of our get parent to true so the get parent is going to be this guy the inventory which I set to false when I click the slot if you remember so now the close should work so now when I open an item I'm going to have nothing because I didn't add anything so in our inventory let's actually add a function ready no let's actually test this somewhere else so let's copy our ad item and what I'll do is I'll add a staff so I'll say add item staff and let's copy that take that and what we'll do is let's put it in here for now so we'll say in and so all we have to do to add an item from anywhere in the game is this in dot add item staff and call its item name okay so now what we can do is play and now I should have a staff in my inventory cool and now I should be able to close and interact with this equip doesn't do anything however you see here we can we can't click the close button so here if I close I can now close the inventory cool and now we have a pretty functional inventory system okay so let's close this and now let's go back to our item info and we want to make the use work now how do we do this so I want you to think about this yourself and I'll give you a hint there's two cases where there's two cases that are use button so there's two things that we need to do or check for I'll say that check for so I want you to think about it and unpause the video and on think or on pause okay so hopefully you've thought about it now these two things that we have to check for is we've actually done this before is one if we have the item already and two if we don't have or if we don't if the item count is is one if the item count is one then we want to get rid of the item completely from our inventory right because we're going to use our item let's say we're drinking a potion right oh and we have 10 potions and I want to drink one potion all I have to do is say count minus equal one right that's easy I just subtract from the count however let's say I have one potion left and I drink that potion I want to remove it from the inventory I don't want to just subtract the count I want to remove it completely now how do we do that well the first thing we have to do is for Loop through our inventory so the first I want to do is for loop I in inventory and then we're going to check to see if we can find the item name this is to check if we have the item at all of that first of all okay first of all this is to check the if we have the item at all but we also wouldn't be able to even press this or press the button if we didn't have an item so it wouldn't really matter but this is really just to find the item so we're gonna basically for Loops through our inventory and find the item that we're trying to use so the item name is up here so we're going to find the item in our inventory right this isn't only just to check if we have it this is to find our actual position our in our inventory right so let's say I'm trying to use a potion at the third slot that means the I will be two because it starts at zero it goes zero one two right so now we have um we have what do you call it um access to our our inventory item okay so now what we want to do is we want to let me just double check something we want to remove from the item so what we'll do is actually really simple we'll just say item count minus equal one now what we can do is we can just check to see if the item count is zero or if it's if it's not zero right so what we can say is if item count is zero then we have to we want to remove item from the inventory that's it okay we'll have an else statement for else well we'll have an else for something else later but that's it so if our item count is zero now we want to actually remove it from the inventory well actually We'll add it right now so we'll say else um count minus subtract one count from the inventory count lot uh variable okay and this is actually really easy let's do this part first because this is super easy it's one line of code bam we're done that is it we're gonna because we have the position of where our inventory item is we just take the count and we subtract from one right and that's it that is literally it's the easiest thing in the world right and yeah and that's it now removing for an item from inventory is a little harder it's actually a lot harder than you might think so to do this we have to actually create a temporary dictionary to hold our inventory okay so what we're going to do is we're going to for Loop through our dictionary again we're gonna go we're going to have to do X because we already used I so we're going to say if for Loop i x in inventory and then we'll say if x is greater than I then we'll take our dictionary and we're going to basically copy every so what we're doing is we're going to look we're going to for Loop through our item no let me explain this a different way so if I have five items in my inventory I and I'm using the item at position three so it's somewhere in the middle I can't just copy I can't tell the the system okay let's copy everything to the left and right we have to manually do this so in order to manually copy everything we have to first check okay in our inventory let's check everything to the left of our inventory from our item use so let's say we're using an item at position three and I I have five items in my inventory at position three I'm going to go from 0 to 2 and copy everything and put it in inside of our item or temporary dictionary okay that's what this line is right here okay and then now I want to go to the right of that item and print and copy everything to the right of that item so essentially we're going to be copying everything in our inventory except for the one item that we are using right so now we have to have an LF function and say if x is smaller than I then we'll copy everything to the left I believe this is the left okay now we've essentially copied everything into our temporary dictionary except for that one item that we are using now why would we do this well it's actually really simple now all we have to do is clear our inventory this is a function built in gudo it's a dictionary thing so now we can all we have to do is say inventory equals temptic because we've copied over the temporary dictionary into a we've copied in our inventory into the temporary dictionary without the item we can now just set it equal to Temporary dictionary and that is it and now what we want to do because we've used up the last item we're actually just going to close our item info so we can just call this function up here so we can say on close pressed okay now the last thing we have to do is fill our inventory slots because now we could do it here but we could also do it here just to update so this will allow us to update our inventory right because the count won't update automatically we have to actually do that so we have to from our inventory item information thing we go up to inventory and then we're going to go back down to inventory container and then we're going to re we're going to update our inventory so let's try that let's see what happens so when I play open my inventory here's my thing I equip or use it and it disappears because the count was uh one so let's actually add few items let's add staff add staff and let's print it now when I play if I use this I gotta update it wait was I not updating it here oh I don't think I was okay I think what I have to do is we have to let me just double check my reference on what I did nope I think okay so what's happening what I believe is happening and most likely is happening is oh I think we might actually be able to do this in the slot so what's happening is the process function is the process is paused on the UI here so it's not able to update now so it's not able to call this function right actually unless I put it in the wrong line let me just double check nope it should be there yeah it should be in that line um let's double check I named this right it's actually just do this nope it's the right path fail inventory slots that should be the right function name okay cool and let's go back to our inventory item let's try one more time and see what we get let's go here we'll equip it close and yeah it only updates when it closed so I think what we have to do is we'll have to say we'll we'll say always and then we'll pause it again so we'll say process raw SAS mode uh disabled there we go and so let's try that and see if that works hopefully nope it doesn't work why is that that's interesting um item count um let's we should actually be able to do this manually oh no we just have to update the info of our slot so let me actually figure this out and I'll be right back all right so I figured out a way I don't know why it's not working for here but it is working for my reference um basically all we're we will do to allow our account to update but avoid errors in clicking our slot is in the process of our label we'll go to always or mode and put it to always so now it'll always update no matter what because the process is always going to be working so now if I equip or close it'll work properly okay so that's that's that fixed so we still have this there to avoid any errors in clicking the slot while our inventory item information is up all right so that is everything for the using the button next up I believe we are going to create the equipments the equipment system okay next up we are going to be doing our equipment system okay so let's get that set up first in visuals and then we'll also do the script so the first thing the visual will actually be pretty easy for the equipment we'll actually have it local so we'll have it as a node and we'll say equip and we'll move this let's move this into the inventory because it's going to be part of the inventory and then in here we're actually just going to let's do this let's go into our inventory go to slot we'll drag that in and let's find our slot pop that in and we're going to make it local and then we're going to delete the count because our equipments don't have account and then let's go over here and disconnect everything we want to go into our script and we're going to delete the script we're going to go to our slot and rename this head okay so here let's move this up maybe right there actually I'll move it right here um it's hard to see where this is so let's pop that in there and let's move this one pixel to the right whoop it's really hard to move Pixel Perfect okay and let's duplicate this um a few times so we have one two three four five and I think that's good so let's actually select the move button by clicking W or selecting it and we'll just move each one of these a few pixels down so we'll have the head the chest the legs this will be the feet put that down there this will be the left hand that right there and this will be the right hand let's actually move that end that a few pixels up there we go okay so let's rename everything this is going to be the chest we have legs this will be the feet this will be the left hand and this will be the right hand but I have to rename it right hand okay so here we now need to create a script that will work for all of these so in our inventory let's create a new folder for this let's say equip equip and in this script we are going to go into here well we have to first create the script so let's say script we'll say equip uh let's actually rename it to something uh no actually let's go to equip and then here all we're going to do is we're going to have the same variables as our item slot this is going to be pretty similar to our item slot in fact we can actually go into our item slot and just copy some things over I think we should actually be able to just copy all this over go into our well first okay let's go back to our clip and add this we don't have a count so we're actually going to remove that and then enter here we're actually going to set the texture in our process so here we'll say um at the icon okay I'll copy it over icon dot texture is going to be equal to okay this is going to err for you but I'm going to put this for now okay so we're going to say inventory.equip at stringself.name at The Icon so let's actually explore what this means and we'll actually create it in the script so let's actually go to our equip and close all other tabs let's open our Global inventory and in our inventory we're going to add a new dictionary in this dictionary we're going to have it called be called equip so I'm actually going to copy let me copy it over the first one and then I'll copy the rest over and just explain what it all does so the first thing we're going to have is a variable dictionary called equip and in this equip like dictionary we're going to have six seven seven keys each one is going to be its own head chest legs feet left hand and right hand each one is going to be unique so we're going to have head et cetera et cetera okay and each one of those is going to have an item inside of it that item is literally from our inventory right so it has the exact same things has a count um the count won't really matter because we're not going to be using it but we're just going to pass it over anyways so from our icon we're actually why don't we load something proper so we can load uh let's load the weapon no actually let's load something else so that way we see if it changes okay so from here we now have head and all that stuff so we want you want to make you're going to want to make one for each um thing so I'm gonna just copy this over for my reference and I'll quickly just scroll through it a little bit so here we have head chest legs feet right hand and left hand if you want more things you can do that really easily okay I'll be showing you how to implement all of these pretty easily so um here for these um image we're probably going to want to actually load something proper again for all of them so let me just do that real quick and there's a fast way to do this for me so if we just select this and say Ctrl R and replace all it'll replace all of them to the iron shield and no more errors cool so it doesn't really matter what we preload but as long as we pre-load something so that way we can load something in later okay so all of these are default so it doesn't matter what it is because we're going to actually load it and change it later anyways so now what we want to do is in our texture we are now equipping it with the we're setting the texture to the equip.string self name so if we have a name called um let's say green arrow we're going to find the Green Arrow and put that in the texture of that green arrow right so we'll load the icon here as well so if we had green arrow it'll load that icon as well okay and next up we have Mouse entered in Mouse exited so we're going to actually want to First we're going to want to let's see if this actually works I've never tried this oh it does okay okay this is a cool trick so if we select the legs and hit control and select the feet left hand right hand and we actually drag the equip we can just select all of them and add the script to all of them at once now let's see if this no it won't work okay so we're gonna have to manually add the mouse entered and mouse exited to each one manually so let's do that right now so let's just add all these Mouse entered um all right so now each one has its own connection and now what we can do is we will want to actually have so originally the you could do you have two options really you can either create another item info for the equipment or what we're going to do is we're going to just use the item info for our equipment so we're going to use this to have our item information on our equipment here so the first thing we'll want to do is actually go from inventory to having it equipped so in our item information we're going to go into our script and now that we have the equipment thing this is just text so there's a lot of different ways to do this really is either we we create another button that's equipped or we just check for equipment or there's so many different things we can do but I'll show both so the first thing we're going to do is we're going to use we're going to take the use button and have it as a from the inventory to whatever so we have few options either it's in our inventory and it's a misc item and if it is a mask item we'll drink a potion whatever we'll use the effect of that item if it's a equipment right if the type is equipment or if the type is a right hand we'll do something with it so on our use press button let me just go to my reference in here what we'll do is we're going to first check for the path so the first thing we want to do okay let me see if I can pull up my reference so this is going to take you a while to type out so I'm gonna just copy it so the first thing you might think of doing is okay well if we want to get the type of the equipment what we can do is we can use match so match is a really good thing to learn but in this case so what we would be doing as we would be saying okay we're going to take the inventory I type and we're going to match it with all of these right so the reason why we're doing this is because we want to see what the type is if the type of the inventory that we're using is ahead then we can equip it right if it's uh legs then we'll equip it in the legs section right so here we we get the path manually of each thing so if it's leg oh I sorry legs twice uh say feet now that this works but it's kind of inefficient it's really long and it'll take a while right so I don't want you to do this but this is a good idea of what how we can one option of what we could do now instead what we'll do we're going to get access to the path of the type and this this is really important you have to make sure that the equipment and the type here on the left are spelled the same otherwise you'll get an error so the path is going to be equal to equip so get parent equipped right here slash string we're going to add the type of their inventory so if our type is head it's going to get the path to head does that make sense so if we in our inventory if we have type head the path will be equal to get parent equip slash head which is right here so we will now have access to our head depending on what sort of type we're equipping right so here we have type head and chest well these are in our equipment but if we had something here so we have weapon we don't want weapon we want right hand okay so this is very important that we make sure that it's right hand or left hand or whatever else here okay so in our item info now what we can do is check to see if the path exists we can say has node path if it does what we can do is we'll say Okay first we'll see if that if that thing has an item if it does or doesn't then we'll make item has true and then we'll just load in the item that we have okay now if it's not no I'm not going to do this but if it if it doesn't exist I want you to tell me what does that mean if the path that we're trying to access of the equipment that we just made doesn't exist what does that mean okay so if if it doesn't exist that means that this is a misc item so we're just going to print that this is a missed item now if you want to create some sort of effect where you add Health to the player you can do that here you can We'll add a comment here um use misc item effect example healing Buffs Etc okay so if you have any sort of buff healing thing whatever this is where you would do it if we're equipping this is where we do it uh let's actually add a comment here equip the item in use in question I will say in use I think that makes a bit more sense okay now I think that is done so I think we actually might be able to test it um I think we have a staff in our inventory so let's just play and see what we got so here we go we have no slots I'm not sure why um if we use it nothing pops up why is that I know why because this is a node and it stayed up there okay we might have to change this let's um change where's change type there it is change type to node 2D and we'll actually try one more time oh where our head our inventory went over there okay let's let's just bring this down all the way here actually no I'll uh we'll do this we'll take all these and then we'll drag it down there we go put it right there hopefully it's not on top of the inventory it is so let's move it a bit more to the left there we go okay let's play one more time this should work okay here's our inventory now I equip and there it is there's our item so if I equip one more time it'll disappear so we'll we'll fix that later but for now we have now equipped something so now I want to be able to click this the item and unequip it so let's actually move this a bit more to the left because I noticed it was still yeah let's put it right there I think that's good okay so now from our slot I want to be able to print or do something so here what we can do actually is we can go into our slot and use that as a reference okay so here remember we have all this so we'll actually just copy this and go to our equip and copy that and then we can say print item name so why don't we do that um let's yeah let's play here we have nothing equipped so let's equip something we close it and here's our item and if I click this nothing happens why is that oh I might not have done this properly let's go to UI let's go to our head um right hand let's go to our right hand and see if that worked okay let's see if this actually worked so let's print something there's a chance it might not have worked oh okay so it did work but it just didn't print the the name so the name was not filled in that's good okay so we just haven't filled anything in so it is printing but it just hasn't printed anything proper okay double check maybe the other ones are printing Okay cool so let's actually take this out so here we can see that if I click this it's printing nothing which is the item name but if I'm clicking on the other ones nothing is printing because there is no item in those so let's close this and in the next part we'll actually work on filling up the inventory or the equipment properly okay one thing I realized is for the information in that is stored inside of our equipment slot we don't actually need these the reason being because our equipment is stored inside of our equipment it's going to be stored inside of our script so yeah here we're not going to print the name we're going to uh let's pass for now let's delete that and and so we have the thing equipped inside of our equip equipped inventory okay so once we've we've worked on equipping an item now we have it equipped inside of our Global script now this is actually really nice because now if we click on it what we can do is we'll set the information from here so in fact we can actually go into our slot and let's Auto load the same thing so we'll say um from here let's put this slot right here and so let's go to our equip we'll Auto load the in item information I will put it right there and let's actually double check that it's correct so let's go to our UI let's go to one of these scripts and let's drag this in and it is the same path perfect okay so we've now Auto loaded this let's go to our slot once more and now we can do this we'll go to our equip and just copy this there we go and so the animation transition in is good however the rest of it is not good because we there is no item name there is no type there is no none of this right however it is stored somewhere okay so I want you to think where is it stored this information like item name where is it right we have it somewhere right otherwise we wouldn't be able to use it here okay hopefully you figured it out it is the same thing here right it's the same idea so in fact we should just be able to do this um let me double check if that's what I actually do I don't think it is no it isn't but um what I do okay so for the name we'll do this so item equip dot self name so it's the same thing right so we're going to take the name of our head so for example if we're a right hand we're going to look for the right hand inside of our inventory I'm gonna go inside our inventory inside of our equip we're going to go to right hand okay here it is here's our what's in our right hand and we're going to load it into the information so into the this thing I'm going to take the name right so let's actually copy this all over and now we can rename this to what it is so this is type this is count this is cost and this is description and now hopefully no errors okay cool let's play and we should be able to equip close this let's open this and now we have this we have the staff right now this won't do anything but it will do something because when we equipped this is the wrong button but if we close it that's kind of what we wanted Okay so we have the item information with our from our Equip to the item info now there's a few things we have to change or kind of understand so the first thing we need to do is understand that the item info should have two things it should have a use button and a quick button so use slash equip and now what we're going to do is we're going to duplicate this and we're going to say unequip I need equip now we could rename it as well like here in our thing but that's gonna it's gonna require a few other things so here we'll just say unequip and now what we can do is we'll make this hidden and so in our UI from our slot what we can add is say you'll pass on it we will say get node dot we can actually say like this actually I'll do it like this whoops okay so we'll say item info dot get node use and hide and then we'll say we'll get the unequip node and show that instead the the button right so in our item info sorry let me close the torch and all that I was playing around with that we're going to go into our nodes here we're going to show the use if it's not or we're going to show the on equip and hide the use If It Isn't So here let's play let's go to our system here let's equip this close this go here and unequip this and obviously nothing happens and but yeah that's it it showed our unequipped so yeah that's it it works now we have to actually we have to disconnect the node because what happened is it used it and it just equipped it essentially and now what we can do is connect this into our node and do something when we unequip now we're going to actually unequip it yeah okay um we have to double check that everything is proper so from our UI things are getting a bit messy sorry so things are getting a little complicated but we'll try to keep track of everything okay so in our slot from our equip here we can hide and show everything right now I believe let me double check that if we do this and close okay so here we see that both are are not hidden so we actually need to do the same thing if we hit the slot so in our slot we have to make sure that we hide and show the proper ones so yeah let's just do this so here we'll show the use and hide the unequip on equip so if we're clicking from our slot from our inventory we're going to hide the unequip and show the use right so it's going to be the opposite okay things are getting a bit complex but we're almost done so let's close that let's go to our Scripts in our item info we're now going to work on unequipping so in unequipping this is very similar so let's go to my let me let me pull up my reference real quick okay so unequipping something is actually somewhat easier but it's still somewhat complex so the first thing we're going to do is we have to check if we have an item in our inventory already so the first thing we'll do is we'll create a local variable inside of our function called has item this will allow us to check if we have the item or not so now what we'll do is we'll for Loop through the inventory and now we actually check to see if we have that item so we can do that by saying if in in dot inventory at the I of our name so if our inventory we're going to for Loop through it look at each name and we're going to check to see if the item type name is the same so if what we have equipped is the same of something in our inventory then all we can do or all we have to do is say item count is item count plus one and say has item is true and that's it so well that's not it but now what we can do is say if has item after is false then what we'll do is we'll say okay well we need to add it to our inventory so what we should be able to do yeah so now what we can do is just say copy it over to a temporary dictionary so we're going to copy over our item from our equipment we're going to add the count to our equipment and then we're going to add it in and that's it I think we actually might also just be able to say add item I think we uh I think we might just be able to say add items so let me let's do that let's uh let's try this this is what I have in my reference but I want to try this so we can comment that out by adding three of these and let's say add item and we'll add the item this one I think that should work nope we got to get the name of it name yeah hopefully uh we have we gotta reference the global inventory so inventory dot add item so if has item is false we'll add it we'll add the item we'll try that for now if that doesn't work we'll end up doing what I did okay and then what we'll do is we'll close the the item info I also actually want to close on equipping where is that equip what we'll do actually is we'll just close it regardless actually yeah no we'll close it here so we'll say if uh if it is an equipment then we'll close it okay and here we're going to close the item info but there's still some things we want to do and that is we have to remove the item from our equipment so we should actually be able to test this see if the ad item works so let's equip something and then let's unequip and it should kind of work well first of all the count didn't work so that's interesting Let's uh equip this on equip and nothing's working okay let's comment this out and see if this will allow it to work okay let's use or equip these twice so we get rid of it and unequip and interesting it's still not working okay let's see let's see what's going on ah right we have to update our inventory ha I knew I was swinging something we'll do that right after so here we'll say get node inventory container and fill these slots so let's actually call that function so we'll fill the inventory slot and yeah we'll use my method for now and now what we should do is if I unequip it yeah it goes count one let's equip both times and then on equip and it should unequip it technically there we go so it does kind of work the only issue now is we got to remove the item from our equipment so let's add a comment say remove item from equip however um let's actually sorry I want to test this part and see if this works we'll add item let's try that little equip equip unequip okay it does work okay so you can do either or so you can either do this or you can just do this I think either or would work actually perfectly because in our ad item we do the same thing we add count we check for if it already exists and then we also add so here we can just add item okay next up in fact you might actually just be able to remove all this but I'm going to test that later and I'll let you know but the next thing we have to do is remove it from our equipment and so the way we do that is we first get our path to what we have so we have to access the path of what we have equipped and the way we do that is by we have the item type so we're just going to say path is equal to string plus item type so we're gonna let's say right hand we're gonna get the path to our right hand and then we're going to get the note of that path and say has item is false and then we're also that's pretty much all we have to do we don't have to reset the information inside of it well firstly because we don't store any of the information inside of it and second because now we'll just set the information to Def Nothing by doing this so let's uh change that to something I actually have say iron shield okay and now we've essentially reset everything so we go into our equipment item type right hand for in this case and say okay we're now going to set everything to default okay so now when I play and I equip something I unequip it it goes back in and it removes it from the slot it's no longer in our equipment right in fact you could print the equipment and test it for yourself but I'll let you do that testing to yourself okay okay one last thing I'm going to do is I'm going to actually test to see if this works so let's actually just play and equip unequip okay it does I don't know why I was doing that then okay and now and now I know okay so um unequipping will just require us to add inventory because in our inventory we actually do all that checking in here so I forgot we actually did that and in our equip sorry in our item info for unequip we'll just close right after we'll fill the slots and then we'll remove it from the equipment that's the only thing that we need to do that we need to add so remove item from equipment okay the next thing we're going to do in the next part is we're going to check to see if we have something equipped which is going to be right here okay so stay tuned and we'll do that in a minute all right so um there was a little bug uh where when I use an item so let me just show you the bug I had so here when I used this up and I used both the entire inventory cleared and that's because here I'm actually clearing it in a for loop I want to do that outside the for Loop so make sure that this is outside the for Loop in case uh that's something that you did as well so let me just remove that print I was debugging this earlier and I was so confused as to why it wasn't working anyways let's continue on into the equipment so when I try to equip something that is already equipped it's going to equip anyways so what we can do is actually reverse this and check if has item is true if it is what we can do is we can just say add inventory add item here let me just let my reference real quick what we can do is we can just say this inventory add item equip item name type so we'll take the item that we have equipped and we'll add it to our inventory and then we'll just do everything as normal so we'll say has item We'll add the item into our equipment Etc et cetera so now when I play the game and I have something equipped so here's our staff if I take our mace and equip this it'll unequip what I have so add it into the inventory and then equip what I have here so if I try this reverse it should yeah there we go and so there is still one bug so here if I have a staff and I already have a staff equipped if I equip it'll still equip it so what I want to do is we want to check to see if that thing is equipped already before now this is a little hard because what's going to happen now is essentially we want to check to see if the item we're trying to use is is already equipped and the same but we also want to make it work so that this work works with miscs as well so what we can do is we can say okay here we'll say if the get node.txt is equal to equip then we will first we'll first check to see if the so here we've already checked we'll do the same thing so we'll say if the node.path as item or actually what we'll do is we'll say we'll put this here as well so we'll have to get the path because we don't have the path and then we will ask okay is this there right um well we already have access to the path okay perfect so here we'll say if get node.path has item is true there is something in it so now we have to check okay if that item so we'll say if we'll get the node we'll say get node.path and we'll say if the node.name is equal to no sorry we have to check the equip so we have to say where is it we can probably use one of the no okay so we'll say uh whoops where'd it go okay so we'll ask so we have we check if the use binance dot text is equal to quip then that means there is something in there if there is something in there or if we have our thing is equipped we're trying to equip something we're going to check if the path has an item if it does we want to check if the name of that item is the same as what we're trying to equip so what we should be trying to equip should be this here we go this guy so we want to check if it's equal to this now how do we get the name of what we have equipped currently well in our UI in our right hand it's a little hard to check because we didn't save it in our local variable so what we can do we got to think about okay how can we actually check to see if what we have equipped is already there well you could go back and add it or what we can do is instead of checking for the name we can actually just check for the icon so instead of the name we'll say get node we'll get the icon and then we'll say dot texture is equal to instead of the equip actually in fact instead of the equip what we can do is check our own Icon by saying get node icon dot texture and if it is we're gonna we'll print something for now already has equipped here we go hopefully that should not error okay if oh I have to add an if statement if okay cool let's try this and see what happens let's equip this equip again and as you can see it says already has equipped so now what we can do is if we already have it equipped um why don't we we can either add the item again or we can yeah let's just do that I think that's the easiest solution honestly let's try that so let's go here let's equip and equip again and nope that's not going to work because yeah because we're actually removing It Anyways okay so here what we can do is we'll say if if it doesn't have it um we will say else then we can do this so what we'll do instead sorry about that I just just figured this out real quick we'll create a variable called item equipped is equal to false and then if all of this is true then we'll say item equipped is true and then at the very end all we have to do is say if item it was equipped then we'll just add it back into the inventory so there's probably a better way to do this but at this point um it's very long and this is one of the ways to do it so if you can figure out a better way to do this I would definitely applaud you and you should definitely try to figure it out but for now this is a very good fix so now what we have is when I play I haven't I equipped my staff I try to equip it again now it'll add it back in at the very end now obviously this changes the format of our inventory but that's okay so now we have a nice system where I can equip things unequip Etc and that's a bug but I'll figure that out in a minute all right last bug I'm not sorry about this guys last bug that we had was basically what was happening is because we were checking for the texture and we say item is equipped is true here well adding an item if the icon is the same so it doesn't actually matter if it's equipped or not if the texture is the same we're adding an item so that was the bug and so to fix that essentially we have to reset the icon texture to something that isn't an item so here we say has item is true but we also have to reset the icon so what what I did is I reset it to the default goodo icon it won't matter what I set it to As Long As I don't use this item in the game because or this icon because this icon won't be shown so it doesn't even matter so now we have a good working equipment system so here I can equip I can equip it'll set here I can unequip equip Etc and there's no bugs so it won't reset or start infinitely adding things into our item and here I should be able to equip this and here's our item Awesome everything in our inventory system works our equipment system works next up we'll be making it so that we can actually equip things and that our soar changes so stay tuned and we'll do that in a minute all right so in our and Slot here in our player remember we added the sword hopefully I showed you how to do that if not it's very simple we just had to add the mesh into our hand slot and rotate it so that it matches our hand and now here let's find a let's find a maze or some sort of other weapon so let's go into our cake it skeletons pack and let's go to the assets and we should be able to find a bunch of things so we have swords helmets hoods Etc we even have staff uh we have a spell book we have a sword and we have a sword half I think this is the half one yeah so let's have the broken one as well so let's pop that in here and what we'll do is I'll just make this local and I'll pop this in let's delete that and here I want to copy over all the same values for the transform so I'll reset that this will be 180 okay the scale clearly is wrong or yeah I reset the scale ah I set the scale to the wrong thing so 180 90 there we go okay and then the position let's reset that and the position oh it looks like actually it's already the right side up let's just set this to 90. so it goes like that and then the position I believe is yeah 0.571 nope or not we'll just manually set it then to right there okay you can copy over the same Transformations but this is what I'm going to use okay so now what we can do is in our process function which we'll make right now we will match the equipment to the sword so what we'll do is we'll say match inventory equipment right hand to name and now we can check for a specific name so what I'll do is we can say um what do we have we have we have to go to our equipment and we'll say iron mace for example so we'll equip if we have iron mace equipped here we go if we have iron mace equipped what I'll do is I'll get the node let's actually create a function called Idol this is a very useful function that I usually do and basically it'll hide all our things so I don't have to do this manually for each node hide so I'll say it all so let me write this out and I'll explain it so high it all and then we'll show the one that we want to show so let's say this is the maze it's not a maze obviously but let's say it is we'll say um no actually let's not re-name it because I already did that here uh here we go iron maze okay and now what we'll do is we'll say broken swordbroken dot show and then here we can also check for what's the other one that we have staff I don't know why we're equipping a staff but that's okay so here we'll say staff if it is we'll do the exact same thing we'll hide all but we'll show this one instead now match has a built-in feature where if I have this this essentially means else so if there's nothing equipped if we don't have anything that's matching these two then we'll just hide all that's what we'll do okay so now when I play hopefully all the errors are gone cool when I play I have nothing equipped and now if I equip our staff and I unequip or I take out the inventory we see our sword is equipped now if I equip the mace it'll change to one of the longer swords and that's cool so we now have a working inventory system with our equipment so we can now equip things now if we want this to always process what we can do hopefully this works I actually didn't test it so we'll test it together so we can set the process to hand slot always and now when I equip something it should automatically switch and you can do this for all of the bones actually so let's actually do that let's set all the process to always and now whenever you equip anything if so this doesn't just work for sword if you equip anything so let's say on your body you want to equip let's go to head if you want to equip helmet whoa we'll put that in here I might do this on my own time just for fun but I'll just show you quickly how you can do that hopefully you've already figured it out but yeah that's it so we can just set this and take the rotation and just put it on top of our character and we can kind of set it to however it works and that kind of looks right that looks like he has equipped and that's it so you would add all the things or you can change the mesh there's a lot of different ways to do this but this is the way I'm going to teach you so you can just use a match function that allows you to equip and unequip things so now when I play I have our helmet on which is uh me hacking technically speaking and then I can equip items so that's really cool awesome all right so let's get into our shop so we're going to create this as a separate scene so let's go into a new node we're going to create it as an area 3D that's going to be the base node inside of here we'll create a collision shape here we'll just give it a simple let's give it a simple sphere and kind of make it that big and then in here we're going to call it shop we'll give it a script in here and why don't we actually put it inside our objects and we can actually make a new folder for this why not and here we go so let's put it in here and save create and then save the shop scene inside that folder that we just made awesome next up we're going to create a shop interface so the shop itself the UI this guy is pretty much nothing there's no not much to it but the UI is where most of the magic is going to happen so let's create a canvas layer it's going to be our shop interface we'll give it shop I'll name it shop you're going to name it whatever you'd like but I'm going to name it shop all right so inside of here we're going to have a few things or quite a bit so we're going to add an animation player or animating the shop in and out let's rename it to anim let's add a control node so that can contain all our stuff for our shop let's add a panel for the background and for the background or for the panel let's make it the same size as the Y in fact actually what we can do is let's delete that and take our inventory or UI I suppose yeah here we go we'll make this local we'll delete this and let's pop this out and delete the UI we don't need that delete the control we'll rename this to shop and in here we can delete the equipment because we don't need that we don't need this let's delete that the close we can keep that but we'll have to disconnect it for now so let's go down here and disconnect some for here we'll go to the title and rename it to stop and then we're going to add a few more things we're going to add some buttons so let's actually yeah let's just duplicate this let's add that here so the way we're going to do this shop is once you have a node here in the middle or Sprite so let's actually find a random Sprite for the equipment where did I put the icons here we go icon iron and we'll put this guy so here's what we're going to have we're going to have a big Sprite of or image of what we want to buy so let's actually look at the transform let's do seven there we go so let's put it right there and the close this is actually going to be closed it's going to be next so we'll go to the right meaning so if we have a list of things we'll go to the right and this one we'll make another one so we'll duplicate it and this one will go to the left so we'll just do like that awesome and then let's have a fourth button it's going to be purchase so if we purchase the selected item okay so let's just try to make this centered I'm not going to use anything any containers to make this centered nicely I'm just going to use um whatever I like so I'm going to rename this to next this to previous end this to purchase let's make sure I spell that right and that is it that's the setup for the node let's firstly add a script for the shop let's go over here add a script awesome and we're going to actually want gold eventually so let's actually add a label for that let's take both of these guys and pop that in there let's take our label put it right there and we'll rename this to gold let's take that say gold and then in our label what we'll do we'll do this part as quickly we'll just have a built-in script here save this as well let's put it right here let's actually take our oh I can't already see that as over shop we'll say shop UI okay let's go to our shop actually I think I saved these shop scripts somewhere else yeah there it is so let's actually move that shop script in here although that might not work because yeah so I have to rename this guy as well so shop UI and then let's take this guy in here awesome and for a gold what we'll do is we'll have a global gold value so in our game script oh we already do awesome so in our script here what we'll say is text equals um gold plus string game dot gold and that's it so now it'll print out our gold right there okay all right so from here we're going to go into our shop actually let's animate our shop first so that way we can actually interact with it from our game so from here as you probably know already all we have to do is do Trans in and Trends out so let's add those two trans out and from Trans in we'll go from here so let's uh take our shop go to layout transform and take our position key that we'll create a reset why not we'll go here and we'll reset that go to zero key that so now we have this and in Trends out we'll go from 0 0 here the key that right there and then from here we'll go to 650. whoops 650 if I can type there we go and now we have a transition outwards okay so in our reset let's set this as our starting position so in our shop all we have to do now is well first of all we have to actually add or shop UI so let's add this in in our shop now all we have to do is firstly we have to connect the body entered in here and then in the body entered so we have to make sure that we check if the body is the player so we'll say if layer in body dot name then we'll do a bunch of things first we can pause the tree so we can pause the game and then we'll get the shop animation so we'll say get node shop slash anim play transition in and then we're also going to make our Mouse shown so we're going to make our Mouse visible okay and from here that's it so let's uh Delete all this we don't need that and now from here we can actually go into our shop and start doing some things one thing I kind of forgot in my reference at least that we can add it's up to you I'm going to duplicate the title and I'm going to drag it down here I'm going to go to theme override set this to 16 Maybe and this is going to be our description of the item so let's actually move the purchase button a little lower go here and say this is uh description Okay cool so let's actually move it down a little bit and you can position it wherever you'd like but that's where I'm going to put it for now okay in our shop let me just pull up my reference the first thing we need to do is we actually need to Let's actually name this description connect all the buttons so let's go one by one and connect all the buttons so we'll go to pressed add the next add previous and purchase okay now that we've connected all four buttons let's go here and delete those two functions in the so the first thing we need to do is is explore the concept of how we're going to do this so first I want to understand or we want to understand how we're going to switch between items okay so essentially we're going to hold a variable that has the current item okay and then we're also going to have a variable that points to which item we have selected okay and then from here we will Okay so we need an array right so we need an array to basically point out which ones we have selected okay so the reason why we need a pointer or an array to do that is so we basically have an array of things and we point towards which one we want now we actually already have that now if you want to make your shop limited I would suggest you remake it but what I'm going to use is actually let's close all this so we have a bit organized we have this this is the database of all the items we have in our game so we're going to use this as our reference or array or dictionary of items so we have 0 1 2 right so in here in our shop we're going to um create a function first called switch item so let's say uh function switch switch item and we're going to pass through a select number this is going to be the number Select okay so from here let's for Loop through the inventory and what we're going to do is we're going to find the item that we have selected and return it essentially okay so now what we'll do is we'll say well because now we're for looping through the inventory I think we could actually just well I'll test it later but for now this is what I have in my reference we'll say if select is equal to I so meaning we found the item that we have in our inventory then what we'll do is we'll say current item is equal to select so select will Point towards which item we have selected and our current item will hold which item we currently have selected so they're almost the same thing it's just to kind of help us switch okay now from here the first thing we're going to do now here's where we're actually changing everything so here we're going to change for example the texture of the where is it this guy so let's actually rename this to item icon and then what I can do is I can actually take this get node and just replace it with this so say at shop item icon dot texture we'll change it with the icon of that current item so here in our items we're going to go to whatever and take the icon that is already pre-loaded okay and then we're going to set that as our texture now we're going to do this let me just copy this and then or fix the stuff so here we can now load in everything we need so we can load in our title which is the name of the thing then we can load in the description and then here this is the description but I also want to add the cost so what I can do here is I can say get the description instead of setting it equal to we'll just add to it so we'll say plus equals Cost Plus string of our cost no this is a new line so it'll always create a new line for the cost so you'll see what it looks like in a second okay now for the next brought 10 this is actually the next and previous is actually pretty easy all we have to do is say switch item dot current plus one okay now the previous is the same thing but we're going to do negative one so we're going to subtract one okay now purchase will be something else that's a different story so let's um look at that in a second first let's go to our close button because it's actually pretty easy we'll say get tree dot pause is equal to false and then we'll also say get Adam get node anim and play transition out and then lastly we have to let's go to our world let's go to our UI actually in here we say going to copy the captured and we're going to capture our Mouse again so once I close it okay so that's close next and previous okay and on our ready function what we'll do is we'll say function ready and switch to zero okay so now what we can do is play and we'll probably want to add the shop somewhere so let's go to our world let's go to our objects and let's add our shop somewhere so okay what's going on here description uh we have to name it desk like that okay let's play One More Time no that's our inventory whoa something happened there I'll figure that out in a second but that's okay so let's find our UI actually for our shop where is it he's like right there he's kind of in the middle there okay let's try to see if I can get to it it should be somewhere around here there we go okay nothing's happening so let's find out why okay so um I'm not sure why but for some reason the animation in the trends in and out for the inventory UI just stopped working and I had to redo it um but here we go um just make sure that it works for you guys if it doesn't I'm not sure why it just stopped working for me it tried to get the wrong node for some reason I'm not I'm not sure why anyways make sure that works for the shops just a quick um bug fix I suppose I'm in our shop UI we have to actually make sure that this is on always for the promote process okay and now let's make sure we add our shop back in and let's try to test this again so now we can go to our shop by finding it here there we go and now we find our staff our Green Arrow and our iron mace and there we go so now we have a bunch of things that we can transition between so this is a staff with the cost and all that now if you want to go from the this one to the first right all we have to do is actually go to let's go to our shop and and try to figure this out yourself actually I want you to try to figure this out yourself and I will give you the solution if you keep watching so leave paused and thought about yourself and unpause and now to figure this out what we can do is we can actually say if um in in the switch items so what we want to do is we want to check to see the inventory size so when we switch or we can either do it here or here let's do it yeah let's do it in the actual switch item so what we can do is here what we're going to probably be trying to do okay let's try let's try to actually print the select and see what we get so let's print select and see what we get in in terms of the select switch item so let's go to our shop so at the moment it's zero right so let's go here we have one two three three three three and it doesn't let me go above three because what's happening is it'll always just end up resetting at three right um so what we have to do is we have to be able to go from three to one or three to zero so what we can say because the problem is actually select is at three but we're not trying to find three we're trying to find zero so there's a lot of different things we can do we can say if select is equal to three we'll say select equals zero this is a quick fix right because what we can now do or check is to go to our shop to what we'll get is go back to staff and it'll just constantly rotate and we can select for zero and reverse now this won't really work but what we can do is instead say if select is equal to zero what we can do is actually say is select equals to inventory items dot size now inventory.size is going to return three right one two three okay okay so it'll make select equal to that final thing now here for the select we can say is equal to size is equal to three right so now when I'm not not inventory sorry let's close that now let's go to the shop and now when I go from oh that's an interesting bug from Green Arrow to iron mace um to stuff we can now rotate through all the items right and we can go backwards we should be able to go backwards interesting okay um what we can try to do select we might have to actually add it in the previous so or we might have to actually check the current item instead all right sorry about the mix-up the select we actually have to check for negative one and then the select we have to set it to the size minus one because this position the final position of the inventory items is 2 and not three so just to kind of re confirm with everything the reason why it will never go above three for example is because here we're setting current item equal to select right so it'll even if I keep adding to it it'll always reset it to that previous number essentially and here we'll reset it by going from if we're at three we'll reset it to zero if we're at negative one or if we're trying to go to negative one we'll reset it at two right so select will now be equal to two now this is adaptable to the size of the inventory okay or the sides of the item so the more items I add it won't matter this will adapt no matter what so this is a really nice way to do it all right last up is the purchase button so here is actually pretty easy so all we have to do firstly is check the price with how much money we have so what we can do is say if the inventory gold or I guess game gold is I gotta capitalize this make sure that we reference the correct gold so if we say if the gold is greater than the item inventory we can also do equals so it's up to you really if you want to have one more gold or the exact amount of the cost of the item that we currently have selected then all we have to do is say inventory dot by or um add item and then we have to find the current selected item so the current selected item has a is a number but what we want to do is first find it and that's it and what we actually do is we actually do that right here so we say we can copy this and say the if the I is in range or so we're going to for Loop through our inventory find the select the selected item well in this case we're not going to use select we're actually going to use um current items so I'm going to say if current item is equal to I then we found the item in our inventory size right or our items from here we can say here we'll take the name or if anything actually we could just get the name here we should just do that instead we'll say string that there we go that'll actually make this a lot easier let's just remove that or we could have done what we did previously and get the name if that doesn't work actually we'll do this so This should work though so let's actually try this and that should work so let's actually just go to our well it's not going to work because we don't have enough gold so we're probably going to want to add more gold give us ourselves a thousand gold let's go to the shop which is somewhere around here here it is so we have a thousand gold the cost of the staff is 100. and what do we get we gotta convert this to a string or um an INT so we'll say and and then let's also convert this to an end um yeah so it's trying to convert a or it's trying to compare an inch and a string which is not going to work so let's try one more time and let's try purchasing and okay so we didn't reduce the gold but it should have showed up in our yeah there it is so we had two but now we have three so now let's actually reduce the amount of gold so let's go back here and let's say game.gold is minus equal the cost now the cost is going to be the fun part because now we need to actually find the cost which we can actually just say minus equal this and I think that's it so let's play and whoops let's close the inventory let's go to the shop let's go to open the shop here we go here's our staff let's buy this and boom what do we get it's trying to re so this is a string we got to convert it to an INT we have to say int there we go one more time all right now we try one more time and there we go so now we've reduced the amount of gold let's try buying a green arrow as well in Iron mace close this and here we go so we have a bunch of iron bases some green arrows and that's it so now we can equip these and it works perfectly fine so we now have the we can equip the staff and we'll go back into that let's see if the Green Arrow works and it doesn't but I think that's because we didn't help make it work so that's it that's the shop working all right so the first thing we're going to do is for our save system we have to create a script for this so This is actually relatively simple let's actually close all our scripts let's now close all these scenes that we have open because everything we have so far is pretty much finished so in our global folder we're going to create a file called utils I call this utility folder and I put all the utility stuff in here so um well in this case we'll have save and load so the first thing we're going to do is create a save and load save pass save path and password password is going to be password please don't name yours password because this is not very secure and we're going to create a function for Save and we're going to have a load function okay so for our save function we're going to create a file and we do that by saying a variable file equals access dot open save path with file access right now let's look through this so the first thing we have to understand is file access this is basically calling so in good O3 actually let me take a step back and go to three and before you would have to create a file by saying file access dot new create the file so that that new would create a new file but now this actually allows us to create it like automatically or more so it'll open it if we have something if we don't it'll create it for us okay so that creates or opens the file okay so here we're going to open at the path with this um access if that makes sense so here we're going to write in it right because we're saving we're going to write inside that file we're not going to do something else like read that's going to be for the load so here next line we're going to create a j string file called Json or we're going to set it to json.stringify the inventory dot uh inventory so we're going to stringify our inventory now this works really well because we're just going to take our dictionary of our inventory and just stringify it and that's it okay next we're going to go to file dot Store LINE j string so now all this is it this is our save file um basically we're just going to store our j string inside of our file and that's it now you used to have to close it but now you don't I think it just closes automatically which is really nice so next up in our load we're going to do the same thing but we're going to read the file okay so we're going to do the exact same thing we're going to get the file that we have and we're going to read it okay so this would do the same thing it would make a new one but because we should already have one we should have already saved by now then we'll just open what we have so far okay now the first thing two things we want to do is to check if file is empty if not file meaning if file is invalid then we're going to return a file is also equal null then I return so I put these I think realistically you only should need one of them but um a while ago when I was working on my own game and I was trying to use this for some reason it would pass this but not this and it would return on asking if null is file or this file is null so I just added both I'm not sure why but maybe they fixed it either way I just add both it's basically a double check to make sure that we actually pass through the proper file because now what we're going to do is we're going to check if the file exists so I'm going to say a file exists at save path this is like a triple check essentially then we're gonna actually start loading it and the way we do that is we're going to say if not end of file is reached then we're going to do this thing in here it's almost like a while loop okay in fact I used to use a while loop but that would cause a few errors and here so now what we're going to do is create a variable called current line is equal to json.parse string file.getline now what this does is it'll essentially essentially take our j string and pop it in here it'll go from a Json file into a variable that we can actually read okay so in fact what we can do here let's start testing this right away let's go into our player or something sure let's go to let's do this on our player let's do save well utils.save game first of all let's actually Auto load our script so let's go here Auto load the utils and add it and now we should be able to save game there we go and let's actually load it as well utils.load and now what we can do is in our utils we will print the current line so let's say print current line and then let's play into what we get okay so here we can see we have zero and a bunch of other stuff one so we have two items let's see if that's true yeah we have two items we have count two of the staff and that's it so yeah it says staff over here and that's pretty much it so in fact we can see this file by going into open in file manager and we can go over here to save game bin open it up and and now we can see the Json that we saved in here now it's a little hard to read because it's all in one line but that's okay because we don't actually need to change this manually or we don't need to read it manually so but now we can see that it exists it saved the file and so this is the file that we've created and now we can actually load it back in to our game right so the way we can do that is actually pretty simple well it's not but let's try to make it simple so first we're going to for Loop through our current line okay we're going to for loop I in current line and what this does is it'll actually go from 0 to 1 I believe okay and it'll basically print so if I were to print here let's do this let's print current I I and it should print this dictionary and this dictionary okay hopefully if it doesn't then I'm surely okay there we go so it did it printed the first one like I had zero and then position two or one in this case which is the second item okay so now we can actually reference something by saying I at name right so now it should print the name of everything so like the staff or whatever right so now it'll print staff and iron maze now you might be thinking well this is really useful why well because now all we would have to do is say inventory add item at the current line now this won't this won't actually work I think because oh no it will work let's try this and see what happens so we've saved and loaded meaning we've essentially doubled what we have so we I think we originally had two in one and we loaded in one each now the reason why this doesn't work perfectly is because we're only adding one of everything right so if I have but in the in the case of our save game save game here you can see we have count two so we want to also make sure that we load in the proper account so we can for loop again and for Loop X in the current line of the count and then add that many times now make sure that you convert this to an integer because everything that's stored as a Json becomes a string so a Json is is essentially a string a big long string okay so when we turn it from a Json back into a variable everything becomes a string so we have to convert it back into an integer well for in this case if we we don't actually convert it back into an integer but we we need it as an integer to actually make this for Loop function because otherwise it'll error so you can test it out yourself try it without converting it and see what happens on your side so now what we can do is we can actually go here and take out the save and we would only want to save if we buy something or something right so let's play the game Let's load and now we can see here we have four and two so let's close this let's go to add item nope add item and let's remove the parts where I add items here we go this is where I add a few things and in our shop let's actually go here and say utils.save game and what else and I think that's it so now we should be able to play the game we load it up we now have two and one now let's go to buy something let's go buy something okay so let's buy some staffs some green arrows some maces and now we have five four and three so let's close that and close the game it should have saved because we bought some things so now let's load open the game and as you can see the inventory has saved and loaded so that's awesome our inventory works completely fine now if you want to save and load the equipment you would do the exact same thing and you would have to handle the loading of the equipment as well so I would urge you to do that on your own and hopefully you are at the point where you can do that on your own if not I would urge you to revise the inventory the entire inventory tutorial and series and lectures so definitely go over them again if you don't know how to do this again in the in the equipment to either save and load it and handle it in the actual equipment Okay so that's it for saving and loading we will probably clean up the game a little bit more mainly in the UI in the next part so stay tuned and we'll get right into that different courses to choose from and you decided to look at this one now you're probably wondering what does this course have to do and what can I actually offer you that other courses don't well it's really hard to pinpoint the uniqueness of a course but my course is focusing on three things I can't promise you uniqueness however I can promise that you will exit this course going from I don't know anything about 3D to being a somewhat intermediate user for 3D and you'll be able to go on on your own and learn more about 3D stuff and create your own game hopefully now the three well four points that you're going to learn specifically in this course we're going to learn one about 3D World creation so we're going to go over a bunch of different things like environments setting up different tile Maps Etc so we're going to go over the creation of a 3D world that you will be able to create the second thing that we're going to do is character creation with complex animation tree now characters can be created in so many different ways now one of the issues when it comes to 3D or any or 2D or 3D is animating now in 3D adding animation grows your options exponentially but it exponentially gets harder and I'm going to go over the very Basics just from animation player all the way into animation tree and we're also going to go into States and state machines now I'm going to go over the complete basics of everything and I hope that you will able to take everything that you learn and create your own character in the future the next part is dictionaries and an inventory system now creating an inventory system can be pretty complex in of itself however I'm going to simplify that with dictionaries so we're going to go over in-depth dictionary explanations and you're going to leave this course hopefully a master of dictionaries and not only will you be able to create another inventory system of your own but you will be able to adapt your inventory system to however you like and the last thing it's not super complex but we're going to be creating a simple AI monster system you'll be able to create a world of various different monsters that you can choose from that you can add to the to your game or to any other game that you create so I hope you guys are ready for this course this course I hope you will have a lot of fun in and good luck okay so the first thing we're going to do is we're going to set the texture for our bars our HP stuff however the we have a few issues so one of the main issues in our bar for our actual Graphics in Godot is going to be this guy so unfortunately we need this to be connecting so in graphic scale or whatever else you have downloaded for Pixel editing we're going to edit these like that and we're going to go over here and do the same thing so we can copy paste and just fill it out and you can do the rest as well we can also do the let's do this guy as well this one is mainly for this guy I believe so we'll set up whichever one we want but I'll set up both of them for this okay and this guy uh we will why don't we just yeah I'll just copy it I will copy this one line over there we go all right now it's everything is full except for most of those obviously but that's okay so now we'll save this and we should be able to just close it will go into our game and what we'll do is we will add a progress bar that I just deleted so it's a little I'm a little sneaky so we'll add the progress bar and in our BG we're going to make sure that we add the progress bar so make sure to import the progress bar so import and import selected I've already done this so here it is so close it and in the background of our texture what we'll do is we'll drag in our new UI or our edited UI so let's make this a little bigger and then let's go to our progress bar and actually drag in the theme BG so we actually can affect it and let's go to BG and we will go to edit region and now let's pick a region for our UI so I'm going to pick this one I think because it's a little cleaner then we're going to select the sub region so it'll be like this this one might be a little hard mainly because of the shadowing but that's okay yeah this one I'll put it like that and that and I think that's good so we'll close that and then for the so we'll close this and we'll copy it to the fill we'll make this unique we'll go to into here and we'll go to the fill and we're just going to take the fill instead zoom out a little bit so here it is here's our fill so let's make sure we select it properly there we go okay I didn't select it really properly so let me actually put on Pixel snap so that I'm setting it properly there we go and the subregion we will do let's take a look at what it looks like well we can't look at it because we didn't we don't have a percentage so let's randomly pick something and then let's go to our progress bar and fill it in so let's go to value and say 50 percent okay now that looks horrible that's not what we want at all so let's go back to our BG now the progress bars are always really hard to mess with because of the texture so I honestly I would I would recommend using texture progress bar in other cases but if you can set this up instead that's totally fine as well so I'm gonna do my best to set this up um with you guys so hopefully we can do it together let's try to find something that is a little nice okay I might we might also have to mess around with some other values in a second but that's okay so let's find a value that fits okay there we go okay put that right there actually and that put that there no we obviously don't want that let's put this right there and that there okay so they're pretty much on top of each other okay that's fine now let's go to not axis stretch is it expand margin nope it's been a little while since I've done this so we're gonna have to mess around with the values of this for a little bit so let me actually pull up my reference here if I don't spend 10 hours looking for it here we go I trust progress for style fill and going to be I remember how we do it okay this is going to be a little tricky so okay we can actually edit this in the sub region so basically this rectangle we need to we need to expand it outwards a little bit so what we'll do is we'll actually do this manually we'll go to here and we'll see if we can edit these values a little bit one by one we'll just drag them up and down and see what we get that's obviously not what we want at all because we don't want that thing under us let's push that up a little bit okay what I'm going to do is I'm actually going to open up graphic scale one more time and we're going to edit the thing again and we're going to remove this guy because it's in the way or I'll just move it down okay so let's save let's go back to good dough and there it is it disappears so let's edit this a bit more all right there we go okay let's let's just do this manually one more time so let's go over here and let's make it pick like right there like that and then see what we get okay let's move that let's move that and we need this guy to move a little bit more to the left which I think we can do here actually so let's do that one more time let's move this upwards that looks good let's go to the left and increase that nope we'll go to six we'll change it bit by bit nope that's not what I want at all so as you can see this is yeah this is kind of a drag so again the texture progress bar would be a lot easier but in this case you would have to separate it completely okay I think this is good enough it's not perfect because it overlays a little bit but that's okay so if we move this up and down it at least looks like kind of progressing in our progress bar okay so let's actually set this to our HP so let's rename this to HP and give it a label we'll do built-in it doesn't really matter and this is really easy all we have to do is say process value equals to game.health now is it actually Health yes it is and the max value we can set it to the max HP which we don't have so we're going to have to set that so let's go to game no no we do Okay cool so that's it let's now also add gold this is also really easy I'll just have a simple label right under it actually no I'm not going to show you because we have it in the shop I think we also might have it in the inventory if I remember uh we don't let's add it to the shop or the inventory then actually let's go over here and add in a label and this will be our gold so let's move this over here and we'll rename it to gold and then we'll add a script built in we'll go over here to the process and the text will just be this so the process will say text equals string game dot Max Health Plus slash slash with health nope Okay I lied this is for the gold okay okay so this is gonna be our health hold on let's put this over here okay let's lock the progress bar I'm losing my head right now it's really hot where I am so okay let's Center this Center this let's expand it to be like that and let's go to our progress bar and remove show percentage and now when I play hopefully it'll show my HP there we go on the top left you can see my HP and I don't think my HP can reduce so let's actually go to our monster where's our monster here we go skeleton and when he hits us where is that on oh I don't know if I ever do add an attack do I it should be over here body.health so we'll say okay let's make this unique because I don't know if it is let's make it unique and save it and we'll say if player in body dot name then we will say game DOT health minus equals five okay let's go to and let's play and let's see if this works and updates if we get hit and it's not so why is it okay let's see player oh um because there's no signal so let's probably do that let's say body entered let's connect it and now it's connected now let's try one more time it's all always the small mistakes all right there we go now it's doing damage to us and there we go so now we have a working RPG action RPG game it's really cool we have inventories we have a shop we have the UI on the top this is really nice and we even have our little shop in the corner I ended up just adding a little um Mage into our shop guy so it's nothing complicated he's same thing he's just a shop with a model now and that's it so I hope you guys enjoyed um that'll be it for now congratulations everyone on finishing the course this course was a really long one it's five hours of grueling content so if you were able to go through all of it congratulations I really do congratulate you and I hope you learned so much from this course and in the future I hope moving forward you guys are able to take what you learned and create your own game and I would love to see it so going forward from here I have a YouTube channel called codingquest or podcasts you can check them both out I have many many more tutorials and many more videos on Game Dev that you can check out to hopefully either inspire you or to help you along your journey I also have a Discord that you can check out if you want to either share your projects or ask for help or just chat with me you can definitely check out my Discord it'll be on my channel at codingquests so check that out and I hope to see you guys around goodbye
Info
Channel: Coding Quests
Views: 28,814
Rating: undefined out of 5
Keywords: Godot, godot engine, godot devlog, devlog, Indie Dev, gdscript, godot 4 tutorial, godot 4, godot 4 grid map, godot 4 mesh library, godot 4 animation library, gridmap godot, mesh library godot, 3d godot tutorial, godot 4.0 3d, godot 4.0 3d tutorial, godot, godot 4.0, godot 4.0 tutorial, made with godot, game development, migrate to godot 4, udemy course, udemy, udemy godot course, udemy godot, godot udemy
Id: vgOlnRASuCw
Channel Id: undefined
Length: 332min 59sec (19979 seconds)
Published: Fri Jun 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.