WEBVTT

00:00.120 --> 00:03.440
Let's add up the acceleration to our player game object.

00:03.440 --> 00:08.400
So over over time we just want this player game object to increase speed.

00:08.560 --> 00:09.720
So let's do that.

00:09.720 --> 00:12.480
So we're going to select our player GameObject in the hierarchy.

00:12.480 --> 00:16.400
And let's open up the player script in Inspector by double clicking on it.

00:16.600 --> 00:20.440
And let's uh what we're going to do we're going to add top of this bit.

00:20.440 --> 00:28.000
So as you can speed by default uh, by we set underneath our player skip which is 4.2 as you can see.

00:28.000 --> 00:32.200
So over time we just want to speed up our player game object.

00:32.200 --> 00:35.960
So we're just going to add top of this speed parameter some value.

00:35.960 --> 00:39.680
So over time just we can increase our speed.

00:39.680 --> 00:40.720
So let's do that.

00:40.720 --> 00:42.200
So we're going to move over to script.

00:42.200 --> 00:44.720
And we're going to make a another variable.

00:44.920 --> 00:47.080
And we're going to make that one as well public.

00:47.080 --> 00:50.080
So we can adjust through inspector as well.

00:50.320 --> 00:52.000
And that will be float.

00:52.000 --> 00:55.400
And we can call this parameter to something like acceleration.

00:55.400 --> 00:57.080
So this will be acceleration.

00:57.080 --> 00:59.680
So I'm going to call it acceleration.

00:59.680 --> 01:05.150
Elevation and by default, if you just want to give a default value, then you can just set equal to

01:05.310 --> 01:07.950
any value you would like to go with.

01:07.990 --> 01:12.390
But I'm gonna give something like, uh, a 0.1, something like that.

01:12.590 --> 01:17.590
And if and close that up with semicolon and what we're gonna do now.

01:17.710 --> 01:22.950
So before we move our, uh, player game object, we're just gonna add top of this speech.

01:22.950 --> 01:24.750
So we're going to type this speech.

01:24.750 --> 01:26.190
So this is our speech.

01:26.230 --> 01:30.310
And top of this speech we're just gonna add up this acceleration.

01:30.310 --> 01:32.310
So we're gonna use this plus equals.

01:32.310 --> 01:38.150
So you need to use this plus equal in order to add top of this speed parameter some unit.

01:38.150 --> 01:40.670
And we're going to add this acceleration.

01:40.670 --> 01:43.390
So we're going to type over here acceleration.

01:43.670 --> 01:46.470
And let's close that up with semicolon.

01:46.670 --> 01:52.710
And to make this number constant what we need to do we need to multiply with time.deltatime as we have

01:52.710 --> 01:55.110
done over here as you can see.

01:55.110 --> 01:58.070
So we're going to multiply this acceleration with our What time?

01:58.110 --> 02:02.550
Total time to make our acceleration constant over time.

02:02.550 --> 02:04.550
So we're going to multiply with time.

02:05.070 --> 02:07.270
Time dot delta time.

02:07.270 --> 02:08.230
And that's it.

02:08.230 --> 02:09.790
So speed uh speed.

02:09.830 --> 02:14.310
We set underneath our player script which is 4.2 as you can see.

02:14.350 --> 02:15.110
And top of that.

02:15.110 --> 02:16.830
So this one is 4.2.

02:16.830 --> 02:20.670
And top of that we're just adding the acceleration and acceleration.

02:20.670 --> 02:22.470
By default we set 0.1.

02:22.470 --> 02:25.270
So 4.2 plus 0.1.

02:25.270 --> 02:29.830
So over time and we do know this update function just going to run every single frame.

02:29.830 --> 02:35.310
So every single frame we just adding top of this speed this acceleration as you can see.

02:35.430 --> 02:41.990
So basically this is the thing in order to uh in order to increase our speed and we're going to remove

02:41.990 --> 02:43.390
this comment.

02:43.390 --> 02:48.070
We don't need double forward slash basically means comment and you can just remove that.

02:48.070 --> 02:51.510
And it's not going to interrupt our code anyways.

02:51.510 --> 02:54.670
So we can just remove that or we can just leave it like that.

02:54.710 --> 02:57.310
It's not gonna interrupt our code.

02:58.380 --> 03:01.700
and we're going to press down control S in order to save our skip.

03:01.700 --> 03:04.100
And let's move over to unity by now.

03:04.300 --> 03:07.500
So over time we're going to able to see this speed parameter.

03:07.540 --> 03:11.740
Just going to just going to increase over time.

03:11.740 --> 03:14.180
So just let's have a look on this.

03:14.380 --> 03:18.380
So just wait for a little moment and you're gonna able to see that.

03:18.780 --> 03:22.020
So by default we set the acceleration point one.

03:22.020 --> 03:25.700
But you can go with any number you would like to go with.

03:25.860 --> 03:28.100
But I'm gonna leave with a 0.1.

03:28.100 --> 03:34.300
As you can see, as soon as the script just gets compiled we can see our underneath player skip acceleration.

03:34.300 --> 03:36.260
By default we set 0.1.

03:36.420 --> 03:40.100
So let's click on this play button in the top in order to play our game.

03:40.100 --> 03:42.140
And let's have a look on this.

03:42.140 --> 03:45.900
So over time this speed right over here is just gonna increase.

03:45.900 --> 03:47.220
And you will see that.

03:47.660 --> 03:52.140
So just wait for a little moment in order to, uh, start our game.

03:52.140 --> 03:56.780
And we can see underneath our player skip in Inspector Speed just getting increased.

03:56.780 --> 04:00.820
So I'm going to click on this pause button in the top in order to pause my game.

04:00.940 --> 04:03.180
And now if we move over to player skip.

04:03.180 --> 04:05.900
As you can see speed by now is five.

04:05.900 --> 04:13.300
So over time the speed just increasing and increasing by this amount acceleration as you can see.

04:13.460 --> 04:14.860
So I'm going to get out of play mode.

04:14.860 --> 04:18.940
So just click on this play button in the top in order to get out of play mode.

04:19.180 --> 04:21.620
And now we're going to make our player jump.

04:21.620 --> 04:22.860
So let's do that.

04:22.860 --> 04:26.260
So we're going to select our player game object first in the hierarchy.

04:26.260 --> 04:29.340
And let's open up the player skip by double clicking on it.

04:29.700 --> 04:35.660
So what we're going to do now we're gonna uh so what we basically want to do if we press down space

04:35.700 --> 04:41.700
key on our keyboard, then we just want this player game object to jump in the y axis.

04:41.700 --> 04:43.580
So when we press down space key.

04:43.620 --> 04:46.300
But you can check for any key that you like.

04:46.300 --> 04:48.420
So we're going to use if statement.

04:48.420 --> 04:49.940
So let's move over to Skip.

04:49.940 --> 04:52.820
And we're going to do it over here in update function.

04:52.820 --> 04:57.730
Because every single frame we need to check if we press down space key or not.

04:57.850 --> 05:00.890
So that's why we're going to do inside this update function.

05:01.050 --> 05:04.330
So we're going to do some more over here in this update function.

05:04.330 --> 05:06.370
And we're going to use this if condition.

05:06.370 --> 05:10.250
So type this if and make first bracket and some curly brackets.

05:10.250 --> 05:16.890
And you need to put a condition in this first bracket condition that you want to check for.

05:17.090 --> 05:22.530
So in this if condition in this brackets we need to pass a condition which should be totally true.

05:22.530 --> 05:26.250
Something like we can simply say five is greater than one.

05:26.250 --> 05:26.850
Is it true?

05:26.890 --> 05:27.250
Yes.

05:27.250 --> 05:33.290
The condition we put in between this bracket and between this bracket is totally true.

05:33.290 --> 05:38.570
So whatever we're going to write in between these curly brackets by now, it will be executed.

05:38.730 --> 05:41.890
So let's suppose we just want to print out a message.

05:41.890 --> 05:44.770
Something like we're going to say five is greater than one.

05:44.770 --> 05:46.610
So let's print out a message.

05:46.610 --> 05:52.370
And we do know that in order to print out a message we're going to type this debug dot log function.

05:52.370 --> 05:55.400
So let's type debug dot log and make first bracket.

05:55.400 --> 05:59.480
Then close that up with semicolon and you need to pass a string.

05:59.480 --> 06:01.800
So make sure you do in this quotation.

06:01.800 --> 06:07.040
So type the quotation and you can pass the message you just want to see in your console tab.

06:07.040 --> 06:17.240
So I'm going to say something like this condition this condition is totally true totally true true.

06:17.280 --> 06:19.360
And make sure you just close that up.

06:19.360 --> 06:20.200
Semicolon.

06:20.200 --> 06:26.040
So we put a condition in this a condition as you can see five is greater than one.

06:26.040 --> 06:30.320
So the condition over here we put in this first bracket is totally true.

06:30.320 --> 06:34.720
So whatever we're gonna do inside this curly bracket is just gonna execute.

06:34.720 --> 06:40.920
So this line, uh, so this over here, this message just should be pop up in our console tab.

06:40.920 --> 06:41.160
Why?

06:41.200 --> 06:45.200
Because the condition we put in this, if it's totally true.

06:45.200 --> 06:46.000
So that's why.

06:46.040 --> 06:48.800
So we're going to press down Ctrl s to save our script.

06:48.800 --> 06:50.800
Now let's move over to unity.

06:50.960 --> 06:51.960
So we will see.

06:52.080 --> 06:57.480
So whenever we're going to click on this play button at the top to play our game, we will see as soon

06:57.480 --> 07:01.520
as the game's gonna start, that message is going to pop up in the console.

07:01.520 --> 07:05.440
Says, this condition is totally true, so just wait for it to compile.

07:05.600 --> 07:10.880
And now if I select the console tab from here, and let's click on this play button in the top to play

07:10.920 --> 07:11.720
our game.

07:11.720 --> 07:13.640
And let's have a look on this.

07:13.640 --> 07:15.880
So the message should pop up right away.

07:15.920 --> 07:18.280
Says this condition is totally true.

07:19.480 --> 07:20.440
So just wait.

07:21.400 --> 07:26.640
And as soon as the game started we can see the message just getting pop up in the console says, this

07:26.640 --> 07:29.800
condition is totally true, so I'm gonna get out of play mode.

07:29.800 --> 07:30.880
So why this message?

07:30.880 --> 07:32.680
Just getting pop up every single frame?

07:32.680 --> 07:38.600
Because we're doing inside update function and we do not update function runs every single frame.

07:38.600 --> 07:45.200
So every single frame, uh, this line of code just getting executed basically means this message just

07:45.200 --> 07:50.480
getting pop up in the console every single frame because we're doing a update function, as you can

07:50.480 --> 07:50.840
see.

07:51.080 --> 07:57.710
So instead of checking like this and let's suppose you put something like one is L, one is greater

07:57.710 --> 08:00.310
than five is this condition is true.

08:00.350 --> 08:02.950
No, this condition is totally false.

08:02.950 --> 08:09.430
So that's why in between these curly brackets, by now, you're gonna put it not gonna be executed at

08:09.430 --> 08:14.430
all because you put in this the condition, which is totally false.

08:14.430 --> 08:17.550
So we need to put a condition which should be totally true.

08:17.550 --> 08:20.430
So what we're gonna do, we're gonna check for some input.

08:20.430 --> 08:26.350
So we need to use this input dot, get, uh, key function and then make this first bracket.

08:26.350 --> 08:30.710
And this bracket you need to pass the key code you just want to check for.

08:30.750 --> 08:32.270
I'm going to check for space key.

08:32.310 --> 08:36.830
And basically once I press down space key I want this player game object to jump.

08:36.830 --> 08:38.310
So I'm going to check for space key.

08:38.310 --> 08:39.990
So let's go to that line of code.

08:39.990 --> 08:44.870
So we're using this input dot get key function in order to check for input.

08:44.870 --> 08:53.100
So you need to put in this brackets a the key a which uh With which key you just want to check for.

08:53.100 --> 08:55.100
So I'm going to check for my space key.

08:55.180 --> 08:58.860
So I'm going to pass Keycode key code dot space.

08:59.100 --> 09:00.380
Key code dot space.

09:00.620 --> 09:03.700
It basically means we just pressing down space key.

09:03.740 --> 09:09.780
So if input dot get key key code dot space basically means if we press down space key then this line

09:09.820 --> 09:11.380
of code just going to be execute.

09:11.460 --> 09:13.860
You can check for any key that you like.

09:13.860 --> 09:16.620
So you can check for this a as well as.

09:16.620 --> 09:22.180
So it's going to check for if you press down a key then what's a whatever you're gonna do inside this

09:22.180 --> 09:23.060
curly bracket.

09:23.100 --> 09:24.460
It's just gonna execute.

09:24.460 --> 09:26.300
So I'm going to check for my space key.

09:26.300 --> 09:29.820
So that's why I'm going to pass a key code dot space.

09:30.060 --> 09:34.300
And what I'm gonna do now I'm going to make a function in order to jump.

09:34.300 --> 09:36.420
So I'm going to make it somewhere over here.

09:36.580 --> 09:40.740
And for function what we basically need to do, we need to type this void.

09:40.940 --> 09:44.580
And we have to name the function what we want to name it.

09:44.580 --> 09:46.540
So I'm going to call it something like jump.

09:46.540 --> 09:51.860
And then you need to make this first bracket and some curly brackets in order to make the function.

09:52.060 --> 09:56.940
So for function you need to type void and you have to name the function what you want to name it, and

09:56.940 --> 10:00.220
make sure you just make this first bracket and some curly brackets.

10:00.260 --> 10:04.660
And let's suppose you just didn't assign it to something like public or private.

10:04.660 --> 10:08.940
So this function automatically by default it's going to be a private function.

10:09.140 --> 10:11.860
And let's suppose you just put public.

10:11.860 --> 10:14.820
So it's gonna be public function.

10:14.820 --> 10:18.140
Or you can just make this one as well private.

10:18.500 --> 10:25.020
And and if you just remove this private or public it's gonna be automatically by default gonna assign

10:25.060 --> 10:26.860
a as a private function.

10:26.860 --> 10:32.980
And now what we, I want to do in this function or inside this curly brackets, I just want to print

10:32.980 --> 10:34.460
out a message for now.

10:34.460 --> 10:40.220
So I'm going to type Debug.log in order to print out a message and make first bracket.

10:40.220 --> 10:41.980
Then close that up with semicolon.

10:41.980 --> 10:46.700
And you need to put a string that you just want to see in your console tab.

10:46.700 --> 10:50.770
So I'm going to say something like player jump, player jump.

10:51.810 --> 10:56.210
And right now what I'm going to do I'm going to remove this message.

10:56.330 --> 10:58.410
Message from this if condition.

10:58.410 --> 11:01.370
And what I'm going to do I'm going to call this jump function.

11:01.370 --> 11:02.690
So we just made the function.

11:02.690 --> 11:07.010
We also need to call this function in order to execute this line of code.

11:07.010 --> 11:09.730
So we're going to call the function inside this package.

11:09.730 --> 11:13.490
So we're going to call the function over here which is in our case jump.

11:13.530 --> 11:17.450
And you need to make this first bracket and then close that up with semicolon.

11:17.450 --> 11:21.170
So let me explain what we basically doing right here here.

11:21.330 --> 11:24.370
So we're just using this if condition in order to check.

11:24.370 --> 11:30.410
And we're checking if input dot get Kiki code dot space basically means if we press down space key on

11:30.410 --> 11:36.450
our keyboard, then what we do is we're just calling this jump function and jump what we have done inside

11:36.450 --> 11:42.290
this jump function, we just printing out a message in the console says player jump as you can see.

11:42.290 --> 11:48.570
So as soon as we're gonna press down space key on our keyboard, this jump function And this jump function

11:48.570 --> 11:53.490
over here we can see is just printing out a message in the console says player jump.

11:53.530 --> 11:54.730
As you can see.

11:54.730 --> 11:58.210
So we're going to press down control S in order to save our skip.

11:58.210 --> 12:00.130
And now let's move over to unity.

12:00.690 --> 12:05.970
So whenever we're going to press down Space key on our keyboard, you will see that message is going

12:05.970 --> 12:08.490
to pop up in the console says Player Jump.

12:08.770 --> 12:11.130
So we're calling that function jump function.

12:11.130 --> 12:14.130
And we do know what we're doing inside that function.

12:14.130 --> 12:20.610
We just simply, uh, just, uh, simply just printing out the message in the console says player jump.

12:20.610 --> 12:21.370
So let's have a look.

12:21.370 --> 12:24.770
So I'm going to click on this play button in the top to play our game.

12:25.010 --> 12:31.370
And once I press down space key on my keyboard that message is just going to pop up right away.

12:31.370 --> 12:32.650
So just wait for it to compile.

12:32.690 --> 12:34.730
I'm really sorry for the noises.

12:35.010 --> 12:40.690
So if I press the space key, as you can see, as soon as I press down space key in the console tab,

12:40.690 --> 12:44.290
we can see a message just getting pop up, says Player Jump.

12:44.290 --> 12:48.920
So instead of printing out what we just wanted to, we just want to make clear jump.

12:48.920 --> 12:54.000
So let's get out of play mode, and let's double click on that message in order to move that line of

12:54.000 --> 12:54.400
code.

12:54.760 --> 12:59.920
And instead of printing out message what we want, we just want to make our player jump.

12:59.920 --> 13:02.360
So before we make our player jump.

13:02.360 --> 13:07.640
So if we head over to unity and then select this player game object in the hierarchy and press down

13:07.680 --> 13:10.400
F in order to focus on that game object.

13:10.400 --> 13:16.000
What we need we need a reference of this rigidbody 2D component of this player game object.

13:16.040 --> 13:17.800
Then we can make our player jump.

13:17.800 --> 13:22.480
So basically what we need if we select our player game object then go over to Inspector.

13:22.520 --> 13:27.480
We can see we just added up a rigid body 2D component to this player game object.

13:27.480 --> 13:35.000
And this rigid body 2D component is responsible for velocity, adding force, and lots of other things.

13:35.000 --> 13:39.560
So we need a reference or we need a link of this rigid body.

13:39.560 --> 13:41.880
Then we can make our player jump.

13:41.880 --> 13:47.510
So what we need we need to grab the reference of this rigid body of this player game object in order

13:47.510 --> 13:49.150
to make our player jump.

13:49.230 --> 13:53.670
So let's move over to our code and let's go to top of our class.

13:53.670 --> 13:58.710
And we're going to make it public so we can see underneath our player skip basically over here.

13:58.910 --> 14:02.150
And the component we're looking for is a rigid body 2D.

14:02.150 --> 14:05.110
So you need to type the component that you're looking for.

14:05.110 --> 14:07.190
So in our case rigidbody 2D.

14:07.190 --> 14:08.990
So we're going to type rigidbody 2D.

14:09.230 --> 14:12.110
And we have to name the component what we want to name it.

14:12.110 --> 14:18.230
So I'm going to call it something like RB and then close that up semicolon RB short for basically rigidbody

14:18.270 --> 14:18.710
2D.

14:18.870 --> 14:21.630
So we just made a variable rigid body type.

14:21.790 --> 14:27.550
So so we're going to able to see this slot or this parameter underneath our player.

14:27.950 --> 14:30.670
So we're going to press down Ctrl S to save our script.

14:30.670 --> 14:32.390
And let's move over to unity.

14:33.950 --> 14:38.630
So underneath our player we're going to able to see that rigid body slot.

14:38.670 --> 14:44.070
So what we have to do we need to drag this rigid body component into that slot.

14:45.590 --> 14:52.430
As soon as this player skip gets compiled, we can see underneath our player skip, a slot just pops

14:52.430 --> 14:54.950
up and it says none Rigidbody 2D.

14:54.950 --> 14:56.790
Basically, it means empty.

14:56.910 --> 15:01.630
So what we need to do now, we need to select this rigidbody from this player game object.

15:01.630 --> 15:04.630
So make sure you select the player GameObject first in the hierarchy.

15:04.630 --> 15:06.350
Then move over to Inspector.

15:06.350 --> 15:12.070
And we're going to take this rigid body of this player game object and drag it into that slot.

15:12.150 --> 15:15.670
And now we can see we have player rigid body reference.

15:15.670 --> 15:20.350
As you can see means we have the reference of this rigid body 2D component.

15:20.350 --> 15:23.390
And now we are able to make our player jump.

15:23.390 --> 15:26.470
So let's open up our player script by double clicking on it.

15:26.470 --> 15:29.110
And let's move over to this jump function.

15:29.110 --> 15:30.670
So we're going to remove this message.

15:30.670 --> 15:34.550
Instead of printing out message we just want to make our player jump.

15:34.550 --> 15:35.430
So what are we going to do.

15:35.430 --> 15:37.030
We're going to go over to RV.

15:37.230 --> 15:39.710
Simply we're just moving over to rigid body.

15:39.710 --> 15:45.860
And then use this dot add at first function in order to add the force and then make this first bracket.

15:45.900 --> 15:48.060
So this rb dot add force function.

15:48.060 --> 15:51.980
It's going to take the direction in which direction you just make one.

15:52.020 --> 15:53.740
You just want to make the jump.

15:53.860 --> 15:57.740
So we just want this player game object to jump in the y axis.

15:58.140 --> 16:03.260
So if we select our player GameObject in the hierarchy and then move tool, we don't want this player

16:03.300 --> 16:05.300
game object to jump in the x axis.

16:05.300 --> 16:06.420
Something like this.

16:06.460 --> 16:09.900
We want this player game object to jump in the y axis.

16:09.900 --> 16:15.380
So we're going to use a vector tool because that vector two is just going to have x axis and the y axis.

16:15.380 --> 16:22.140
So we can just set y or x according to what we really need to do.

16:22.140 --> 16:23.380
So let's go to that.

16:23.460 --> 16:24.940
Uh let's go to script.

16:24.940 --> 16:29.540
And we're going to use this new vector tool and sorry new vector two.

16:29.580 --> 16:32.940
And we do know uh, so make some uh first bracket.

16:32.940 --> 16:36.980
And this vector two is just going to have x axis and the y axis.

16:36.980 --> 16:40.890
So we don't want to make our player jump in the x axis.

16:40.890 --> 16:45.130
So that's why in the x axis we're going to put zero f and in the y.

16:45.170 --> 16:49.530
We just want to make our player jump some units something like 5 or 7.

16:49.530 --> 16:53.130
So let's make another variable for our player jump.

16:53.130 --> 16:56.410
So let's go to the script and let's go to the top of our class.

16:56.410 --> 16:58.370
And we're going to make another variable.

16:58.370 --> 17:02.690
So let's make this one public so we can adjust underneath our player skip.

17:02.810 --> 17:04.130
And that will be float.

17:04.130 --> 17:06.530
And we can call this one something like jump height.

17:06.530 --> 17:08.850
So let's call it jump height.

17:09.010 --> 17:11.570
And by default you can give any value you like.

17:11.570 --> 17:13.770
So I'm going to give something like seven.

17:14.090 --> 17:16.170
And let's close that off with semicolon.

17:16.170 --> 17:22.170
And if you just want to do just want to close that off something like this, then you can adjust underneath

17:22.170 --> 17:24.090
your player skip as well.

17:24.090 --> 17:25.770
But I'm gonna give a default value.

17:25.770 --> 17:28.290
So that's why I'm going to set equal to seven.

17:28.810 --> 17:33.290
And now what I'm going to do in the Y I'm going to pass this jump height and the jump height.

17:33.290 --> 17:36.290
By default we set seven as you can see.

17:36.290 --> 17:43.210
So this just gonna be seven means our player GameObject will jump in the Y axis with seven unit, something

17:43.210 --> 17:43.850
like this.

17:44.050 --> 17:47.490
So this rb dot add force function is.

17:47.650 --> 17:49.130
It's basically a force.

17:49.130 --> 17:50.530
So that's why as a comma.

17:50.530 --> 17:53.290
So you need to put this comma as a second argument.

17:53.290 --> 17:56.170
You need to pass this force mode to d dot impulse.

17:56.210 --> 17:56.610
Why.

17:56.730 --> 17:58.530
Because this is a force.

17:58.530 --> 18:03.330
So that's why as a comma you need to pass the force mode to d dot impulse.

18:03.330 --> 18:06.130
So firstly we just pass the direction.

18:06.130 --> 18:08.450
And the second thing we need to pass the force mode.

18:08.450 --> 18:13.450
So we're going to type force mode 2D dot impulse and then close that up with semicolon.

18:13.450 --> 18:16.850
And we're going to press down Ctrl s in order to save our code.

18:16.850 --> 18:20.530
So let me explain one more time what we basically doing.

18:20.970 --> 18:22.610
So let me explain that.

18:23.810 --> 18:25.250
So just wait for to compile.

18:25.250 --> 18:28.970
And once our script gets compiled we are ready to do that.

18:28.970 --> 18:34.730
So what we're doing firstly we're just going over to this RB basically means we have the reference means

18:34.730 --> 18:41.000
we just moving over to this player game object this is rigid body 2D, and we're using our force function

18:41.000 --> 18:42.720
in order to add the force.

18:42.720 --> 18:45.040
And we do know it's going to take the direction.

18:45.040 --> 18:48.240
So in the Y we set jump height as you can see.

18:48.400 --> 18:53.600
And in the x we set zero basically means we don't want to jump in the x axis.

18:53.640 --> 18:56.040
We only want to jump in the y axis.

18:56.040 --> 18:57.960
So that's why we set a.

18:58.000 --> 19:01.240
We just replace that y with some height and jump height.

19:01.280 --> 19:06.240
By default we set seven and we can see as well underneath our player skip.

19:06.240 --> 19:08.800
And we can adjust it over here as well.

19:08.800 --> 19:11.240
So that's why we just made that field public.

19:11.280 --> 19:15.160
And make sure you just press down Ctrl s in order to save your skip.

19:15.160 --> 19:17.160
And now let's move over to unity.

19:17.280 --> 19:21.360
And let's click on this play button in the top in order to play our game.

19:21.360 --> 19:22.480
And let's have a look.

19:22.480 --> 19:26.640
So whenever we're going to press down space key that jump function just gonna call.

19:26.640 --> 19:29.360
And we do know what we're doing inside that jump function.

19:29.360 --> 19:31.040
We just making our player jump.

19:31.040 --> 19:33.880
So if I just press down space key as you can see.

19:33.880 --> 19:35.480
So I'm gonna get out of play mode.

19:35.520 --> 19:40.360
I just want to make the player speed a little bit low so we can just test the jump.

19:40.360 --> 19:45.080
So I'm going to make this speed parameter underneath my player skip something like one.

19:45.080 --> 19:49.520
And now let's click on this play button in the top in order to check that jump.

19:50.160 --> 19:54.040
And you can adjust the jump height as well underneath your player skip.

19:54.080 --> 19:55.840
It's totally up to you.

19:56.960 --> 20:03.080
So now if I press down space key on my keyboard, as you can see, as soon as we press down Space Key,

20:03.120 --> 20:07.960
we are able to see this player game object just jumping in the y axis.

20:08.400 --> 20:10.720
And and that is cool thing.

20:10.720 --> 20:11.960
I hope you get the idea.

20:11.960 --> 20:18.240
So I'm gonna get out of play mode and make sure you just press down Ctrl s in order to save your project.

20:18.240 --> 20:21.760
And also make sure you select your player game object in the hierarchy.

20:21.800 --> 20:25.920
Then go over to Inspector, then overrides and then click on this Apply all.

20:25.960 --> 20:30.400
If you made your player game object a prefab, so make sure you just do that.

20:30.440 --> 20:36.560
Or you can just skip this part as well if you haven't made this player game object prefab.
