Godot Visual Scripting 3d Character Controller Simplified - Codeless Game Development

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today we'll be talking about how to build a 3d character controller right inside the dot engine using visual script we're not going to use in real course you're going to be doing a codeless game so it's going to be in 3d so we'll have an empty scene here so i'm going to clip our 3d scene so it's going to have a special here so first of all i want to quickly build up something here so i'm going to click and create a new understand i'm going to call it a texture and [Music] we might need that texture there so we're going to need also scene folder right clicking and selecting that so um first let's add a static body the starting body is more like a know that enables you to be able to actually bring in a body that can be able to collide with other bodies so if you use some other ones it will not be able to sense objects or bodies like kinematic bodies so we have this 3d here so i'm going to select that create the static body so it's going to ask me for a pollution but before i actually have that i like to add my mesh instance i'm going to right click on it and add child um node there and that will be my mesh instance so my meshing style is more like you have been able to create like a physical but if you look right here sorry body is doesn't really have a physical body here so but if i click here in my inspector once i select this select my inspector and click on mesh i can be able to create a plain mesh or a cube so i'll go for a plane because i'm trying to build the plot for the meantime so it will give me a floor here so i can use my controls here so maybe other um tutorial will start with the basics of godot and the basic controls and the entire thing so i just want to do a quick review of our visual scripting here so if you look at here it still has this uh option here or this uh a lot and now that he needs the collision body so that when you put a kinematic body on it or some other kind of region but it doesn't pass through it can be able to sensitive so study bodies are like more like physics bodies so i'm going to right click on it and click on add child node i'm going to add a collision shape so my collision shape uh i would like to make it uh if you look at here when i select it it's asking me if i ship for the collision so i'm going to i would like to use a box so for you to be able to do that you have to use this controls here to surround it so it's more like whenever an object comes across this particular shape it will not be able to pass through wherever the collision is so the collision is like what tells the the the mesh what the this way it can actually allow things to pass through so once if i didn't put it here anything that passes through here any rigid body will fall through this place so i'll just want to make sure it covers the entire part of it okay so there will be better ways of doing this that's just work with this for the mean time so we'll have this so we'll have a collision body here so right now i'm going to call this my floor so i can snap this and you have a flop so one more thing i want to do so i can be able to appreciate what i'm actually doing here is um i would like to add some materials to it so if you don't know what materials about um you can build actually open that click on mesh and you have a material here and click on that and new special material so when you open that you can click on that and you have video so in the arbiter you can specify the color you want it to be right so but we want it to actually have a real texture so that we know when our our shape is actually uh our character is actually moving so we really build other things i'm doing it so that if you don't have the knowledge of out of your characters you can easily work with that so um or building environments in godot so i'm just going to go down i want to get a texture so i'll quickly go to here i have my texture and how you import textures just go to where you have it so i want to use that one there and i'm just going to drag it and drop it inside here so and that's quickly how you can be able to import the texture so with this in my video i will just select that and drag it right inside here and i have my this thing here so i want to save this automatically so right now you don't see so i'm going to press ctrl s and i have my scenes here i'm going to double click on the scene i'm going to call this my 3d character controller so i'm going to save that so you can actually uh make this a bit bigger you can tile it more so if you want to tile it if you want to do more materials we can go in details with that so in this uv one you can just go for let's say five and five so you can actually have more details here so we can do more things but we're going to leave that for now so i'm going to right click on the spatial and i'm going to add a kinematic body all right so um i want to build all these things inside here i can build it outside but i won't build everything inside here so after that i want to add a mesh instance so the mesh instance is there but you're not seeing anything yet so i'm going to go to the mesh and i want to use um a capsule this time around so look at this is a capsule so i'm going to get my capsule and i'll bring it up so see what i actually want to do i want to use it to actually build a very simple character so i'm going to select that and duplicate bring this down when i bring it down i can use my rotation and rotates this character like that okay so we want to be able to do a very simple character here so have this car will go up to this place so let's kill it down use your skill here and kill this car down like that and i would like to do under ctrl d to duplicate it again and drag it down a bit like that so i would like to scale it out like that so currently we'll have um there's a very simple character that can be able to move once you actually select this you should be able to move all of them all at once okay so right now we want to be able to make sure that everything is working as we want so i'm going to drag it down make sure it's actually pushing the floor there okay so let's select this so right now we need to add a collision shape so that when you collide with something it will stop okay so i'm going to right click on this and add a collision shape to it and i think i'll want to use in my inspector here i'm going to click on that new box shape and i'm going to bring this up now mind you it's also increasing get up on that so you have to make sure you uh be professionally so i'm going to drag this off by clicking on this uh my move to here so you can go from the top to cover so i have something like this all right so i'm going to select this and call this a player so i could actually make this player to be different but for now i don't want to be different you could actually do more on it so right now we want to just be able to use our arrow keys or wasd we want to be able to actually move this character so but i want us to start with um the movements that's using the arrow keys so i'm going to save that so right now we can right click and add a script so let's go into the coding part now so adding the script will have our player so this is the let me call this a 3d player i like to put underscore on the scope here under scroll movements all right so now where is he saved so i'm going to click here and it's saving the scene i don't want to do that i want you to create this phone scene so i'm going to click on that go back here and create a new folder call that my scripts so it's very good that you actually have different folders for different things so you have the name of the folder there so click on that and click on create make sure you have this visual scripted not that or gd script these are for real codes so i'm going to go for visual coding video scripting so you should have your scripting my limits in so many ways but for those that do not really want to go into our coding um they can actually use a viewscript to do a lot of things so you can easily switch from 2d 3d okay and then go back to the script so this what we have here all right so let's go back to our scripts so the first thing you want to do let's start with the process okay process function so the press washer enables us once you actually call during the process step of the main loop so once the game starts this whatever is there you can actually use this process for more business buddies but the process here will actually work very well so i'll click on oop on that and i'll get my process okay so if you are confused click here you can type process if you don't see that and just click on that and click on open and you have a process here so the thing we want to do right now is i want this to move okay so for it to be able to move we need um some uh notes okay that will actually be using here within this particular place in the programming blocks so i'm going to right click inside here and i'll type action so action is uh being able to bring in some things like buttons pressed so when you press a button you should do a particular thing okay so i will say uh i can say um when you press up this is up okay um i'm going to make another tutorial will do the detail this is the default buttons you're going to see but you can create your own buttons but that will make that material a bit longer so i'm just going to print up there up to actually make it actually move forward okay so if you look again i want up to make it move this way on down to make it backwards then right this way and left that way or that's left arrow key that way so i'm going to go back to my script and right now i want to bring in another pen here so we are in display and displays the kinematics all right so if i right click again i can type move and collide so the movement collide is enables moves the body along the vector of real vector here then the body will stop if it lights so whenever you actually use this it can be able to move an object or a kinematic body you see it's under the kinematic body you can move it and it will stop whenever it collides the particular body so i'm going to open that so this the function or sorry they know you're actually going to use to make this work okay so if i select that i can be able to if i can do this i will have to select this and i will tell my program um don't just run this because if i do it that means that once the game starts it starts moving automatically all right so um i'm going to do something here i'm going to click drag it out and once i drop it i see it click drag it out drop once you drop you see condition there if you don't have you can type it there and when you open it now you're giving a condition telling it whenever what should happen before you should run this code all right so i'm going to tell it whenever uh you press this action here you should do this so the action we have selected is up okay so it should do something so what should it do it should move now the next thing i want to understand now are the axes here so if you look at here you have the x axis y and z axis so let's go back to 3d and you see the axis so if you look at up here you see your y your z and the x so the x is actually the red one z is the blue one so this is the z so but right now i'm going to go on the x axis so that means uh positive x forward okay so let's try that out and see so i'm going to go to script and say we want you to move uh about one um i don't think i know the actual measurement here but just say what you need okay forward and i'll press enter so i can now is going to whenever i press the off it will check what i expressed and it's going to move it along on this axis here so i'm going to right click and click on play this sorry uh before i will do that i need to put up something so i'm going to right click on this and add a camera so because without a camera you cannot be able to actually see the player so i'm going to add a camera to this scene and i'm actually into the player so when he's moving he moves along with the player so if you come in here you can actually see the camera here so i'm going to bring in the camera the camera is facing here so look away spacing right now so if you do this you see it's facing the other side so i'm going to use the rotation and rotate it to face my character okay so to position it properly i like using my view and true viewport and i'll make this one to be viewing the character or i use this one to set it properly i can select this and set it okay so i have something like this so you can actually make the player smaller if you want to but you don't need that i would prefer to make my scene a bit bigger so i'm going to go back to my one view and remove this preview here so select the floor and i'm going to scale it up a bit a bit here so use that and build it up to that place okay so have this so the next thing i want to do is uh let's test this game and see he was actually working with the off button so once you right click and play it you see so if i press up it's actually going forward can you see that okay so right now this uh thing is working on his own so i'm going to make it a child of this particular one so it becomes a child meaning that i just dragged it inside it if you look here click and drag it inside it becomes a child of the player so that means if i right click and play again let it see when i move the camera moves weights so you can see that okay so this is a basic 3d movement i'm going to add more things to it to make it more interesting so um let's go back to our code so let's add more of subscribe things here so right now i want to now add the other buttons so for the next button i want to control d select that ctrl d i'm going to drag this down the next button is the down button so i'm going to do it for the done so i'm going to tell it um now this is true now we're going to work with this for the mean time we're going to use starting animation part so i'm going to go to when it's done we want another condition so if you check this if it checks that another button is first so if this button is pressed it should do something else so we want to move on so i'm going to click on that in case you don't understand this you can just right click move and collide okay and just don't use move and slide just move use move alkali so just get that and put that there so this timer i'm going to do negative one on the x axis remember the axis okay negative one so it's going to be going backwards so let's test it out and be sure that we are on the right path so go forward backwards forward backwards so if it's too fast you can actually change it to um about uh i think it's a bit faster let me just change it to about 0.5 and this one minus 0.5 okay so now i want to add the other ones here so i'm going to quickly uh duplicate this one too and remember we'll have this let me arrange this properly so that you are pretty sure what's happening here i'm just going to drop this here and there's one there very organized so i'm going to go from done again so when it's done it should check for another one so this one will be i'm going to go for let me go for left is ui left so i'm going to drag this here and go for [Music] this duplicate this again ctrl d to duplicate and i'm going to add this here and select that so this amount i'm going to press 0 now if i go back to this so if you look at our axis let me select my player and see my answers so the z as is the yellow one so positive z does this way all right should be uh right and negative z is left so i'm going to go back to my script so because i'm using my left button so it's going to be negative z so i'm going to put here minus 0.5 so it's on the z axis okay so quickly i'll do the raw one bring in my condition again i'm and to select this onto d and just drag this inside here so i'm going to select this one control d2 so it's just the same process i'm repeating it again and again to put this here but this time around this one will be 0.5 enter so you want to do this if not it might not really be able to you know come in so you type it in and press the key so select this one and this will be my right okay so let's go and check it out so this when you press right so right click on it and play this scene so if i use my arrow keys now i can go forward backwards left right forward backwards left right so that's how we create our our basic character movements within our 3d now we have not done the idea of rotation we'll not do it for now just want to go with the basic uh character motion so right now i want to be able to transform this my 3d scene to make it more interesting so one of the first ways i like working is uh let me just call this i'm going to right click that create another um standing body so this one will actually be the wall okay everybody and um right click and create a mesh so my mesh instance will be um i'm gonna use a cube this time around it's a new cube mesh okay so i'm going to slide that cube mesh and scale it up like that so i'm going to have something like this still it's up i'm using my scale tool here let me drag this off a bit like that so we'll have something like this so we can quickly put this around our scene here so i'm going to select that drag it up a bit and that's part okay so um i want to import another cereal or texture so i'll quickly get this texture here and let me select this and make sure i'm selecting i'll just select it drag it inside this texture here so now i want to [Music] add a texture to it i'm coming with the collision so i'll select when i select this mesh and just come in here and click on materials is empty right now so click here special okay special material i'll click on this and go to albedo so for this i'm going to just drag this that should be greek and just drag my brick inside here so look at that let's see it's coming all right so we'll have this you know so it's not looking so cool so it can be able to actually go for uv and we can go out so let me go for nine nine okay i think let's take this down so to three so it's gonna be a bit better so we'll have something like this so i can easily um increase this a bit it's much more interesting all right so we'll have something like this so let's quickly add um a collision shape to it collision shape and my collision shape i'm going to add still a box eq so selecting that uh i've already moved this i'm just going to quickly bring this close to this one and drag this out so i want this to cover the entire wall and this will actually make the player not to be able to pass through that wall so i'm going to drag this up you're going to use this red don't use any other side of it so just use those red things there to scale it in different answers so you drag this back and make sure it's okay so we'll have something like this then this will be okay for our work okay so save my work and select this i'll call this wall so i'm going to select this wall and okay i think i made a big mistake here let me go to my mesh and drag my mesh back here let's drag this back and run this back i actually moved it out of alignment so we'll have to take them all back to the center here we'll have this our wall so if you look at here you see what's happening here so i think i have to select these two both of them and bring them to the center here let's select that and see okay now is actually in profession right now so we'll have this i'm going to drag this down to this place check something on the floor oh our fly is a bit not [Music] okay um there is one more button that i wanted to know if you want your mesh to be united so that when you scale this it will affect that one and select that and click on that button so whenever you do you select any of them and scale it will scale all of it so i'm going to do the same thing to this one click on that button so if you look at that it does restore the objects children ability to be selected so that's when you actually uh select it so if i just click on that that means that all of it once i select it whatever i do to affect the children too that's the other ones below this one below it so i'm going to select that and i'm going to do control d so i have an award so i like to put a very simple wall in front of him just scale it down a bit like this and use my rotation to rotate it this way okay so we'll have that so let's just quickly um select this ctrl d and pull this one to this side and um i think i'll want to use both of them and control d use this and drag it forward to this point so i won't just have a very long thing here so last i want to have one more wall here let's select that wall ctrl d i'm going to use my rotation and rotate that okay so i have something like this so hopefully i'll just put that now we're actually not doing any level design i just want us to put our character and have him begin to [Music] go through or pass different walls that will be blocking it so i'm just going to drag this make sure it's actually done so i'm going to duplicate again and put this one backwards okay so i have something like this now so this is the scene that we have actually built so i'll go to my card controller and do my final testing here and i can just go see if i try to pass it's going to block me if i try to fall out it's going to block me so i have to actually evade this it did that and so i have this so okay so how to start walking back again so uh i used to design a very simple game so we'll be designing a very simple game with this so but this is the first time we're going to look at so we have learned how to be able to use our character our visual scripting to work with our character controller so we can give it actually control it so you have the different buttons the function the conditions and just basically have about four different rules i'll be using here and then the function that will be here okay so thanks for listening and um do subscribe and i will also be posting more videos on this particular project so that we can design a very simple 2d game using video scripting alright thank you for listening
Info
Channel: visualcodinghub
Views: 532
Rating: undefined out of 5
Keywords: Godot Game Engine, Godot Visual Scripting 3d Character Controller, Godot Visual Scripting Game Development, Visual Scripting, Codeless Game Development, Godot 3d Game Level Design basics, 3d Character controller
Id: 1x3C1gqhOmc
Channel Id: undefined
Length: 29min 50sec (1790 seconds)
Published: Thu Oct 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.