to move and jump and double jump So first, let's create Floor so I use this naming convention to separate And let's choose an albedo color over it and We can also drag this to our player and let's also give a y-value of one and if it's not reset it you must you should reset it before you do that also, so let's give a Value of one so that it will stay on the floor and let's make it closer The camera to it a little bit and Yeah, that's good. That seems good. All right. Now we are going to create a character controller Which basically? Which will be a script but first we're going to need to add a character controller component to our player so if you click add components and search for character controller You can add it There are some properties here. These are for to be used in our Moment script we won't be using any of them they will only create a gravity and We will use the Move function of character controller. So one thing to mention the character controller comes with a capsule capsule Collider so that you can delete the existing one because you don't need them and If you have a another character you can adjust the height and radius based on your character, so Let's create a script to Program our Movements Let's create a c-sharp script named player and we're going to attach it You can just click the scripts and drag it to our player and it will be attached attached so double-click on the scripts And I'm using we just decode because I'm used to this I'm used to this editor, but if you're using Visual Studio that's totally fine. So we're going to reference the character controller From our player game object so in the start Of the script we are going to reference to the character control controller component from our player now which is here, so So yeah to move our character, what do we need we need both horizontal movements horizontal inputs Which will get it from the input that get access method and We also need The vertical input So We're going to use the controllers move method and we are going to as you can see this method takes and vector free parameter and we are going to feed our Horizontal and vertical vertical inputs as xn z X and Z values so Let's create a local variable for that horizontal input and for the Z we're going to get the vertical input and in here we are going to pass this direction So, let's save it and return to unity If you open the file and if you open game and test it You see we can move but the movements happens very quickly and this is because this update runs runs once per frame and Frames frames per second can depend can where I Depending on your hardware. So to overcome this issue to make this count to make this calculation You can see ours our player can move Better smoother or net? So we also need a speed variable So that we can control the speed of our player let's create a float variable named move speed and We can give five F as a default value now. We want to make this invisible in the inspector so we are going to Make it through serializable we do this because Because this is a private variable This is only This is encapsulated inside the script. So other scripts cannot reach it and change its its value But we want to see it in the inspector, right? So that's why we are making it serializable, but it's still not reachable by the other scripts So this is the main difference by doing? this public because this way other scripts can also reach to this variable and change it so Yeah What we're going to do with this move speed variable is that we are going to multiply our direction with this move speed and If we return to unity out and you're going to see this will our speed will pop up and Now our speed is applying and we can change it in the write our run time here can make it slow And if you notice you can also make it negative and that will change the magnet directions opposite way so Now that we don't use any physics to move our character we are going to need a gravity functionality to to know, you know make the Character fall off of any plane Because right now you see it doesn't fall off it just floats on the air so for that reason we are going to implement our gravity functionality and this is just just simple as You know subtracting a gravity value from the directions y-value, so What do we have? We have a gravity and What do we want to do with it? We are we want to subtract our direction Y in each frame so that way we are going to have a Simple gravity functional functionality as you can see ya right now our player can fall off So now that we have gravity We can also have a jumping function. That's right So what is the first requirements to have a jump functionality is to get an input? right If the jump button is pressed Then we are going to give The direction Y a value and we can create a jump speed Value for it and let's Have a defect will default value of 3.5 and we are going to assign this in our code so let's examine what we are doing here we are initializing Direction value direction vector free with We give the jump speed value why and then we subtract our gravity Now and then remove now what happens in the next frame we are reinitialize this direction and our Direction Y In a in a temporary like say let's say direction Y in a temporary Direction Y and after our after these calculations if we reset it if We say the direction Y Is the is this? temporary value then This won't be really initialize to 0 in each frame Instead it will be Remembered the previous value of direction Y. Well, we always remembers and stored this value. So let's It stayed in the game mode let's start the game again now, let's test it now So we don't jump again That's increased jump speeds So nothing happens again So maybe if we Lower the gravity a little bit or a lot a little bit and Jumps beats, let's increase the jump speed We can get yeah Maybe a lover Jump speed is better So the falling off happens too quick I think it is the same reason in The start where we move too much too quickly if you multiply it with time If you multiply this kind of calculation time data file, that's time maybe It will happen much smoother So let's test it and I think this jump speed value is too much right now Maybe - Yeah, it's it floats because gravity's too low where is the reset it To these values and now yeah, we have a smoother Jumping right But another issue is that we can jump infinitely. So let's solve this What do we need to check? Whether we are on ground or not, right? So rather than creating a temporary value at boolean value we can use the controllers is grounded Property and this will give us whether whether our player collides with any floor or not Well, actually Whether it is colliding with another Collider because in unity there is no but not a concept or in treaty There is not a concept of floor if floor has a mesh Collider and players player also has a you know caps : and if two of them collides then It's grounded value here will return it true. So let's check this so we said if we are on the ground we can jump let's test this and now as You can see we can only jump once So when can this be true one can be double jump if we are on the ground? That means in the feature when we jump we can also double jump and in here We can do the same calculation Multiplier Lawyer, all right zero, let's give a value of 0.5 and I want to multiply this jump speed with my double jump multiplier and when I did Double jump when I performed the double jump action I can now Say that I can't double jump anymore and also Not forget to include this condition in our if statement here, so let's add it So if you press the jump button and can begin double jump then double jump it is that so let's return to unity again and Play our script and Yeah Just like this You can play with these values and however you want You can you know give point eight Which I actually like better I like this Can also maximize it? So yeah, this is the basic functionality for a character controller in the next videos we are going to add camera to the scene and also we are going to Import a 3d character in a later videos. So see you in the later videos. Bye