WEBVTT

00:00.040 --> 00:02.360
We can jump as many times as we want.

00:02.400 --> 00:03.560
So let me show you.

00:04.200 --> 00:07.840
Let's click on this play button in the top in order to play our game.

00:07.840 --> 00:10.120
And let's have a look on this.

00:13.640 --> 00:15.760
Just wait for a little moment.

00:16.360 --> 00:22.840
So if I press down space key, as you can see, we jump it a lot and we can jump as many times as we

00:22.880 --> 00:23.280
want.

00:23.320 --> 00:26.640
Let this player game object come to this ground.

00:26.640 --> 00:28.440
And if I just press down space key.

00:28.480 --> 00:34.440
As you can see, it's jumping a lot and it's gonna jump as much as we want.

00:34.480 --> 00:39.560
So I'm going to get out of play mode and let's me, uh, let me show you one more time.

00:39.560 --> 00:42.360
So I'm going to select my player game object in the hierarchy.

00:42.360 --> 00:45.880
And I'm going to make the jump height a little bit less something like four.

00:46.080 --> 00:51.640
And if I just click on this play button in the top to play our game, we're going to take a look on

00:51.680 --> 00:52.200
that.

00:52.920 --> 00:59.720
Uh, we can jump as many times we want, so just wait for it to come play our game.

00:59.840 --> 01:04.610
So if I just press down space key, as you can see, we can jump even in the air.

01:04.650 --> 01:06.410
So we need to stop doing that.

01:06.410 --> 01:07.930
So let's get out of play mode.

01:07.970 --> 01:08.730
What are we going to do.

01:08.730 --> 01:14.890
We're going to create a parameter a bool parameter which can be true or false to just keep track of

01:14.930 --> 01:18.090
if this player game object is standing on this ground or not.

01:18.130 --> 01:23.170
If this player game object is standing on this ground, then we're going to make our player jump.

01:23.170 --> 01:29.050
And if this player game object in the air, we're not going to make this player game object to jump

01:29.050 --> 01:29.810
in the air.

01:29.850 --> 01:35.290
So I'm going to drag it on top of this ground, because in the start of the game this player just gonna

01:35.730 --> 01:37.330
be top of our ground.

01:37.330 --> 01:38.170
So that's why.

01:38.210 --> 01:42.930
So let's select our player GameObject in the hierarchy and open up the player script in the Inspector

01:42.930 --> 01:44.330
by double clicking on it.

01:44.810 --> 01:48.570
And let's go to the top of our class, something over here.

01:48.570 --> 01:53.890
And we're going to make a parameter or a variable to just keep track of if this player game object is

01:53.890 --> 01:55.930
standing on this ground or not.

01:55.930 --> 01:59.660
And we're going to make a bool parameter, which can be true or false.

01:59.660 --> 02:02.940
So I'm going to make a private so it doesn't need to be public.

02:02.940 --> 02:04.340
So we just made it private.

02:04.340 --> 02:06.980
So we're not going to able to see that parameter.

02:06.980 --> 02:09.620
And in it our player skip in the unity.

02:09.660 --> 02:14.300
We're not going to able to see that because as you can see we just made it private.

02:14.300 --> 02:17.700
And that will be pulled which can be true or false.

02:17.700 --> 02:22.380
And we have to name the parameter or the variable which uh, what we want to name it.

02:22.380 --> 02:26.100
So I'm going to call it something like is crown is crown.

02:26.100 --> 02:29.220
And let's start or close that off with semicolon.

02:29.380 --> 02:31.900
And we're going to move over to this start function.

02:31.900 --> 02:35.620
And we do know that start function get call in the start of the game.

02:35.620 --> 02:39.580
So in this start of the game we're going to set that is crown parameter to true.

02:39.620 --> 02:40.060
Why?

02:40.140 --> 02:46.060
Because uh, this uh player game object in the start of the game just gonna be top of this crown.

02:46.060 --> 02:47.660
So that's why it is Crown.

02:47.660 --> 02:53.540
We're gonna set in the start of the game, uh, to true, because we're gonna be top of our crown,

02:53.540 --> 02:54.260
so that's why.

02:54.260 --> 02:55.460
So let's go to script.

02:55.460 --> 03:00.230
So in this start of the game we're going to set is brown, we will set equal to true.

03:00.670 --> 03:02.630
And let's close that up with semicolon.

03:02.710 --> 03:05.950
So in this start of the game we set a second parameter to true.

03:05.950 --> 03:10.590
Because in the start of the game, this player game object is just going to be top of this round.

03:10.590 --> 03:11.470
So that's why.

03:11.510 --> 03:15.590
And once we make this player game object jump so it's going to be in the air.

03:15.630 --> 03:18.710
Then we're going to set that is ground parameter to false.

03:18.990 --> 03:25.310
Uh y we're gonna set it to false because once this player game object jumps uh, it's not going to be

03:25.310 --> 03:26.470
top of this ground.

03:26.510 --> 03:28.390
It will be in the air.

03:28.390 --> 03:31.710
So that's why we're going to set this ground parameter to false.

03:31.710 --> 03:37.310
So we just created that parameter in order to check if this player game object is standing on top of

03:37.310 --> 03:38.750
this ground or not.

03:38.750 --> 03:40.390
So let's go to script now.

03:40.390 --> 03:41.310
And over here.

03:41.310 --> 03:46.870
As you can see we're checking if input dot get key Keycode dot space basically means if we press down

03:46.870 --> 03:51.550
space key on our keyboard, then what we're doing we just making our player jump.

03:51.550 --> 03:56.990
So at that same time, I want to check if this player object standing on this ground or not.

03:57.000 --> 04:01.880
So if we press down space key at the same time, I'm going to check if this player game object standing

04:01.880 --> 04:04.160
on top of this or crown or not.

04:04.520 --> 04:08.640
If it's standing on top of this crown, then we're going to make this player jump.

04:08.800 --> 04:11.680
Else we don't want this player game object to jump.

04:11.680 --> 04:15.840
If this player game object not not in top of this crown.

04:15.840 --> 04:21.480
So somewhere in the air, then we don't want this player game object to jump at all.

04:21.480 --> 04:27.080
So that's why in over here if we press down space key on our keyboard or not.

04:27.080 --> 04:32.240
At the same time, I'm going to check if our player game object is standing on that ground top of that

04:32.240 --> 04:33.280
crown or not.

04:33.280 --> 04:34.160
So we're going to check.

04:34.160 --> 04:38.880
So we need to use this n in order to check with a second condition.

04:38.880 --> 04:43.880
And we're going to check if is crown is equals equals to true means.

04:44.240 --> 04:49.080
So we using this equals equals to equals equals sign in order to check.

04:49.200 --> 04:54.880
And what we're checking we're checking if is crown equals equals to true basically means if we're standing

04:54.880 --> 04:59.890
on top of this ground or not, because we created that ground parameter.

04:59.890 --> 05:05.890
In order to check this player game object is standing on top of this ground or not, as you can see.

05:05.890 --> 05:11.330
So what we're doing, we're checking if input dot get key Keycode dot space basically means if we press

05:11.330 --> 05:17.330
down space key on our keyboard at the same time, we're checking his ground is equals equals to true

05:17.930 --> 05:24.130
basically means if we're standing on that ground or not, so is ground is equals equals to true basically

05:24.130 --> 05:26.170
means we're standing on that ground.

05:26.210 --> 05:30.050
Then what we're doing, we're just making our player jump, as you can see.

05:30.090 --> 05:32.490
And after jumping we're going to set this is gone.

05:32.690 --> 05:34.730
This is ground parameter to false.

05:35.050 --> 05:36.370
Why we're going to set it to false.

05:36.370 --> 05:39.130
Because once we make this player game object jump.

05:39.130 --> 05:40.610
So it's going to be in the air.

05:40.610 --> 05:45.130
So that's why this game object not going to be on top of this ground.

05:45.130 --> 05:48.210
So that's why we're going to set this ground parameter to false.

05:48.210 --> 05:52.210
After making this player game object jump in the y axis.

05:52.210 --> 05:54.050
So we're going to set after jumping.

05:54.170 --> 05:57.910
So we're just making our player jump over here, as you can see.

05:57.910 --> 06:00.190
So after jumping we're gonna set his crown.

06:00.190 --> 06:02.790
So we will set is crown equal to false.

06:03.190 --> 06:03.750
Uh, false.

06:03.750 --> 06:06.110
And let's close that up with semicolon.

06:06.110 --> 06:09.910
And we're gonna press down control S in order to save our script.

06:09.910 --> 06:11.870
And now let's move over to unity.

06:12.390 --> 06:14.030
So, uh, we're checking.

06:14.310 --> 06:19.670
So we're checking, uh, if input dot get key keycode dot space basically means if we press down space

06:19.670 --> 06:25.190
key on our keyboard at the same time, we're checking his crown is true, as you can see.

06:25.230 --> 06:27.550
Means we just standing on that crown.

06:27.590 --> 06:28.510
Then what are we doing?

06:28.510 --> 06:30.510
We're just making our player jump.

06:30.510 --> 06:33.150
And after that, we're just setting his crown to false.

06:33.150 --> 06:36.590
As you can see, as soon as we just leave our crown.

06:36.590 --> 06:38.150
So let's go to unity now.

06:38.510 --> 06:44.910
And as you can see, we're not able to see that private parameter which is bool we recently created.

06:44.910 --> 06:48.670
And let's suppose you still want to see that private parameter.

06:48.710 --> 06:51.550
Then what you have to do you need to move over to inspector.

06:51.550 --> 06:53.590
In the top right you can see three dots.

06:53.630 --> 06:56.320
So just click there and then click on this debug.

06:56.520 --> 07:03.280
And as soon as we have chosen debug underneath our player script by now we are able to see this is ground.

07:03.400 --> 07:06.880
So let's click on this play button in the top to play our game.

07:07.000 --> 07:10.480
You will see this ground in the start of the game is just going to be checked.

07:10.480 --> 07:11.640
Basically means true.

07:11.680 --> 07:15.840
And once we jump this is just going to be unchecked means false.

07:16.000 --> 07:22.360
So if I just press down a space key on my keyboard, as you can see we just made our player GameObject

07:22.720 --> 07:23.240
jump.

07:23.280 --> 07:29.560
But the problem is that for the next time, if we just press the space key on our our keyboard, we

07:29.560 --> 07:33.080
not making our player jump at all for the next time.

07:33.120 --> 07:37.680
Even we just pressing down space key multiple times on our keyboard.

07:37.720 --> 07:37.960
Why?

07:38.000 --> 07:42.640
Because this is ground is false, as you can see underneath our player script.

07:42.640 --> 07:46.720
So we're going to get out of play mode and I want to go back in normal mode.

07:46.840 --> 07:50.880
So what we have to do we need to go this top right one more time.

07:51.040 --> 07:57.130
Uh just click on that three dot, and then click on this normal in order to go back in normal mode.

07:57.250 --> 07:59.690
So why are we not able to jump for the next time.

07:59.690 --> 08:03.610
So let's move over to scrape because this is ground is false.

08:03.610 --> 08:09.690
So once we make our player jump, as you can see we jumping and after jumping we just setting a is ground

08:09.730 --> 08:11.130
parameter is false.

08:11.130 --> 08:13.850
And once we press done space key on our keyboard.

08:13.890 --> 08:20.050
As you can see we're checking if is ground is equals equals to true means we standing on that ground

08:20.450 --> 08:21.130
or not.

08:21.130 --> 08:26.490
So we do know that once we make, uh, once we set this is ground equal to false.

08:26.490 --> 08:32.530
So this over here, the second condition is false basically means, uh, this one is false.

08:32.530 --> 08:36.850
So once we make our player jump, we just setting is ground parameter to false.

08:36.850 --> 08:39.170
And we're checking for the next time as well.

08:39.210 --> 08:43.810
If we press down space key on our keyboard at the same time is ground is true.

08:43.810 --> 08:49.010
And we do know that once we make our player game object first, uh, first jump, then we just setting

08:49.010 --> 08:52.340
back, uh, sorry, we just setting is ground to defaults.

08:52.340 --> 08:57.980
As you can see for the next time, this is Crown parameter is not true at all.

08:57.980 --> 08:59.540
So this one is false.

08:59.540 --> 09:03.140
So that's why we're not able to jump for the next time.

09:03.140 --> 09:06.420
Because this n n both of this condition should be true.

09:06.460 --> 09:11.100
Means if we press down space key at the same time is crown need to be true.

09:11.100 --> 09:17.020
But we do know once we make our player game object for this, uh, once we make our player game object

09:17.020 --> 09:22.980
jump for the first time, uh, after jumping, we do know which setting is crown parameter to false.

09:22.980 --> 09:25.420
So this one is not true at all.

09:25.420 --> 09:31.740
So we also need to set back this parameter to true once we uh uh.

09:31.740 --> 09:34.980
So we also need to set back is crown parameter to true.

09:35.260 --> 09:41.180
Once we collide with this crown, once we collide with this crown then we're going to make a parameter

09:41.180 --> 09:41.780
to true.

09:41.780 --> 09:45.660
And we do know once we're gonna set this is crown true parameter to true.

09:45.700 --> 09:48.500
We're going to able to jump for the next time as well.

09:48.540 --> 09:51.750
Because if we set it to true and we're checking over here.

09:51.750 --> 09:56.230
If we press down space key on our keyboard at the same time, it's ground is true.

09:56.230 --> 10:00.150
So if we set it to true, then we're going to able to make our player jump.

10:00.190 --> 10:02.590
And after jumping we're just setting back a.

10:02.750 --> 10:06.070
This is ground parameter to false as you can see.

10:06.070 --> 10:11.510
So once when we need to set this parameter true parameter to true.

10:11.550 --> 10:14.270
So once this player GameObject collide with this ground.

10:14.270 --> 10:17.670
So let's suppose this player GameObject make for the first jump.

10:17.670 --> 10:20.030
So it's going to be over here in the air.

10:20.190 --> 10:25.150
And once this player GameObject collide with this ground then we're going to set this ground parameter

10:25.150 --> 10:25.830
to true.

10:25.830 --> 10:32.070
And we do know once we set back its ground parameter to true, we will able to jump for the next time

10:32.110 --> 10:32.870
as well.

10:32.870 --> 10:36.150
So we're going to use on collision enter 2D function.

10:36.150 --> 10:40.630
So basically that function just gonna get called once we collide with something.

10:40.630 --> 10:43.110
So let's suppose we collide with this ground.

10:43.110 --> 10:45.710
So that's the that function just gonna trigger.

10:45.710 --> 10:47.350
So let's move over to script.

10:47.350 --> 10:50.480
And we're going to use on collision enter 2D function.

10:50.480 --> 10:52.080
So we're going to make it in the bottom.

10:52.080 --> 10:54.040
You can make it anywhere you like.

10:54.040 --> 10:56.040
It doesn't need to be in order.

10:56.040 --> 10:59.400
So and we're going to use this Oncollisionenter 2D function.

10:59.440 --> 11:01.720
Make sure you adjust it as I.

11:01.960 --> 11:04.640
So make sure you did as I did over here.

11:04.680 --> 11:06.960
Make sure you just do the same thing.

11:07.160 --> 11:12.440
So this Oncollisionenter 2D function, this function gets called when we collide with something.

11:12.440 --> 11:13.480
So this is unity.

11:13.480 --> 11:19.440
Callback function basically means this function will automatically get called by unity once we collide

11:19.440 --> 11:20.240
with something.

11:20.240 --> 11:23.320
So let's suppose this player GameObject collide with this ground.

11:23.360 --> 11:28.280
Then this function over here get called and we can extract info what we collided with.

11:28.280 --> 11:34.200
By going over to this collision in a parameter we can extract info like name of the game object.

11:34.200 --> 11:37.880
We collided with the tag of the GameObject, anything like that.

11:38.240 --> 11:41.960
But before we do, let's assign this ground as a ground tag.

11:42.080 --> 11:44.920
So how we can assign this ground as a ground tag.

11:44.920 --> 11:47.720
So you need to select the GameObject first in the hierarchy.

11:47.880 --> 11:51.170
So in our case this ground we're going to select in our hierarchy.

11:51.170 --> 11:52.450
So select the crown.

11:52.490 --> 11:56.770
Then go over to Inspector and Inspector and you can see tag.

11:56.810 --> 11:57.930
It says untag.

11:57.930 --> 12:00.690
So just click there and then click on this add tag.

12:00.690 --> 12:03.450
And then click on this plus icon in Inspector.

12:03.450 --> 12:05.930
And you have to name the tag what you want to name it.

12:05.930 --> 12:08.010
So I'm going to call it something like Crown.

12:08.290 --> 12:11.090
And after doing that make sure you just click on this save.

12:11.290 --> 12:16.210
And also you have to make sure select the Crown GameObject in the hierarchy.

12:16.210 --> 12:18.850
So we're going to select our crown in the hierarchy.

12:18.970 --> 12:23.370
And then go over to Inspector one more time and tag you can see untag.

12:23.370 --> 12:26.330
So just click there and we're going to assign it with Crown.

12:26.330 --> 12:28.570
So whatever we just recently name it.

12:28.610 --> 12:29.490
Now we can see.

12:29.490 --> 12:31.930
We assign it this crown as a ground tag.

12:31.970 --> 12:34.050
As you can see in Inspector.

12:34.050 --> 12:36.850
So we assign it this ground as a ground tag.

12:37.010 --> 12:40.130
So now what we're going to do, we're going to move over to our script.

12:40.130 --> 12:43.010
So this function get called when we collide with something.

12:43.210 --> 12:48.380
And we can extract info what we collided with by going over to this collision parameter.

12:48.380 --> 12:52.500
So let's suppose we just want to print out the game object we collided with.

12:52.500 --> 12:57.460
So if this player game object collides with this ground then we're gonna extract the tag of that game

12:57.500 --> 12:57.860
object.

12:57.860 --> 12:58.980
Something like that.

12:58.980 --> 13:01.060
So we're going to move over to script.

13:01.060 --> 13:06.940
And in order to print out a message, uh, we do know we're going to use this debug dot log function.

13:07.220 --> 13:09.500
And this debug dot log log function.

13:09.500 --> 13:12.140
It's going to take the message in a string.

13:12.300 --> 13:13.980
Or you have to pass the string.

13:13.980 --> 13:18.900
So what we're going to do we're going to extract info the name of the game object or the tag.

13:18.900 --> 13:22.740
So we uh we have to move over to this collision parameter.

13:22.740 --> 13:27.620
So we're going to use this collision parameter in order to print out the name of the game object we

13:27.660 --> 13:28.740
collided with.

13:28.780 --> 13:30.580
So we're going to use this collision parameter.

13:30.580 --> 13:32.380
So we're going to move over to collision.

13:32.420 --> 13:35.700
Then we're going to add the game object as you can see.

13:35.740 --> 13:38.300
And now we're going to access the name of the game object.

13:38.300 --> 13:41.140
So we're going to use this dot and then name.

13:41.140 --> 13:43.220
And then close that up with semicolon.

13:43.220 --> 13:47.710
So this function get called by unity automatically once we collide with something.

13:47.710 --> 13:50.830
So let's suppose this player can collide with this ground.

13:50.830 --> 13:52.750
Then this function is just gonna get called.

13:52.750 --> 13:54.710
And what are we doing inside that function?

13:54.710 --> 14:01.190
We just extracting the name of the game object we colliding with by going over to this collision parameter.

14:01.230 --> 14:06.870
As you can see firstly we just going over to this, we just using this collision parameter.

14:06.870 --> 14:12.030
And by this collision parameter we just accessing the game object as you can see.

14:12.030 --> 14:16.070
So collision dot GameObject basically means the game object we collided with.

14:16.110 --> 14:22.790
And after just getting the game object we just extracting the name, as you can see, and we're going

14:22.790 --> 14:25.070
to press down Ctrl S to save our script.

14:25.110 --> 14:26.830
Now let's move over to unity.

14:27.030 --> 14:32.190
So as soon as this player GameObject just wanna collide with this ground, the name of the game object

14:32.190 --> 14:34.910
just gonna print out in our console tab.

14:34.910 --> 14:36.310
So just let me show you.

14:36.790 --> 14:40.230
So wait for a little moment to compile our script.

14:41.430 --> 14:43.950
So we're going to select our console tab from here.

14:43.950 --> 14:46.240
And let's click on this play button in the top.

14:46.400 --> 14:49.960
So as soon as this player came up, it's just going to collide with this crown.

14:49.960 --> 14:55.680
You will see the name of the game object just gonna print out in our console tab.

14:55.680 --> 14:56.680
So let me show you.

14:57.360 --> 15:03.800
So as soon as the game player just collide with this crown, the message in the console gets pop up

15:03.840 --> 15:04.480
says Crown.

15:04.480 --> 15:09.680
So if I just collide with second time, as you can see, as soon as this player GameObject collide with

15:09.680 --> 15:14.680
this crown, the name of the game object just getting a print out in our console tab.

15:14.680 --> 15:16.200
So let's get out of play mode.

15:16.200 --> 15:22.000
Instead of printing out message what we want to do, we just want to set this parameter to true.

15:22.160 --> 15:25.560
So we do know once we set back is Crown parameter to true.

15:25.600 --> 15:30.360
We're going to able to jump for the next time as well because this is crown just going to be true.

15:30.360 --> 15:33.240
And so both of these condition just getting true.

15:33.280 --> 15:36.920
So that's why we will able to jump for the next time as well.

15:36.920 --> 15:41.640
And after jumping as you can see which setting is crown parameter to false.

15:41.680 --> 15:45.290
And we also need to set back is crown parameter to true.

15:45.290 --> 15:50.330
So instead of printing out message, once we collide with this ground, we're going to set this ground

15:50.330 --> 15:51.450
parameter to true.

15:51.450 --> 15:58.010
And we do know once we set back is ground parameter to true, we will able to jump uh for the next time

15:58.010 --> 15:58.730
as well.

15:58.730 --> 16:03.450
So let's double click on that on this message in order to go that line of code.

16:03.450 --> 16:06.890
Or you can simply move over to your Visual Studio.

16:06.890 --> 16:10.130
So what we're doing, we're just printing out the name of the game object.

16:10.130 --> 16:11.810
Instead of doing this thing.

16:11.850 --> 16:16.810
We're just gonna check a if if we collide with this ground game object.

16:16.810 --> 16:19.650
So we're going to extract the tag of that game object.

16:19.650 --> 16:22.650
And we're going to check if this ground has a tag called ground.

16:23.050 --> 16:27.050
Uh, so at that moment we're going to set its ground parameter to true.

16:27.890 --> 16:28.290
Why.

16:28.570 --> 16:31.490
Uh, because we need to check only with ground.

16:31.490 --> 16:37.250
And we do know that, uh, and we can see if we select our ground GameObject in the hierarchy, we can

16:37.250 --> 16:41.850
see in Inspector, we assigned this ground as a ground tag as you can see.

16:42.090 --> 16:43.930
So what we're going to do there.

16:43.930 --> 16:45.900
So let's go to script and we're going to check.

16:45.900 --> 16:47.660
So we will use this if condition.

16:47.660 --> 16:50.340
So make first bracket and some curly brackets.

16:50.340 --> 16:52.380
So what we want to check over here.

16:52.380 --> 16:55.540
We want to check whatever we uh just collided with.

16:55.580 --> 16:59.500
If that game object has a tag called crown tag.

16:59.500 --> 17:05.740
So if we collide with this crown as crown that we do know that we assign it this ground as a ground

17:05.740 --> 17:05.980
tag.

17:06.020 --> 17:08.100
As you can see in the inspector.

17:08.140 --> 17:11.820
Then what we're going to do, we're going to set back is ground parameter to true.

17:12.020 --> 17:14.620
So firstly we will move over to this collision.

17:14.620 --> 17:20.580
So we're going to use this collision parameter in order to extract info the game object we collided

17:20.580 --> 17:20.980
with.

17:20.980 --> 17:22.300
So we're going to use this collision.

17:22.300 --> 17:23.980
So let's use this collision.

17:24.180 --> 17:26.500
So collision dot game object.

17:26.500 --> 17:29.580
And then we're going to access the tag of that game object.

17:29.580 --> 17:31.780
So we're going to use this dot and then tag.

17:31.820 --> 17:35.100
And we're going to check if that tag is equals equals to ground.

17:35.100 --> 17:37.860
So make sure you just make this quotation.

17:37.860 --> 17:42.740
And in in between this quotation you need and you need to pass the tag name.

17:42.740 --> 17:44.240
So we're going to check foreground.

17:44.240 --> 17:46.440
So that's why we're going to pass this round.

17:46.440 --> 17:49.360
And we do know we assigned that ground as a ground tag.

17:49.400 --> 17:52.280
It's basically means we collided with this ground.

17:52.280 --> 17:56.800
So what we need to do in that moment we'll set this ground parameter to true.

17:56.800 --> 18:02.680
And we do know once we set back sorry is ground parameter to true, we will able to jump for the next

18:02.680 --> 18:05.400
time as well because we're checking over here.

18:05.400 --> 18:11.200
As you can see, if we press down space key on our keyboard at the same time is ground parameter is

18:11.200 --> 18:11.400
true.

18:11.400 --> 18:13.200
So both of these condition getting true.

18:13.200 --> 18:16.640
So that's why we're going to make we're going to able to make our player jump.

18:16.640 --> 18:21.640
And after jumping we're just sitting back is ground parameter to false as you can see.

18:21.920 --> 18:24.440
So we colliding with this ground over here.

18:24.480 --> 18:27.680
And it's basically mean what we need to do right now.

18:27.680 --> 18:28.800
We need to set back.

18:28.800 --> 18:31.800
So we're gonna set is ground equal to true.

18:31.800 --> 18:33.720
And then close that up with semicolon.

18:33.720 --> 18:35.480
So let me explain one more time.

18:35.480 --> 18:39.320
So collision dot game object basically means the ground game object.

18:39.320 --> 18:42.490
So let's suppose this player game object collide with this ground.

18:42.490 --> 18:46.850
So Collision's GameObject basically means our ground GameObject by now.

18:46.850 --> 18:51.130
So Collision's GameObject basically means the GameObject we collided with.

18:51.130 --> 18:52.810
So we're gonna collide with this ground.

18:52.810 --> 18:57.370
So that's why this collision GameObject basically means this ground GameObject.

18:57.370 --> 19:03.370
And after going over to that GameObject, what we're doing, we just accessing the tag as you can see.

19:03.370 --> 19:05.570
So we're gonna collide with this ground game object.

19:05.570 --> 19:08.970
So we basically just going over to this ground game object.

19:08.970 --> 19:12.210
And then we accessing the tag of this ground game object.

19:12.210 --> 19:15.290
And we can see we assign it this ground as a ground tag.

19:15.330 --> 19:17.250
As you can see in the inspector.

19:17.250 --> 19:19.970
So basically means this over here just gonna be ground.

19:19.970 --> 19:22.490
And we're checking if that ground is equals.

19:22.490 --> 19:28.570
Equals to ground basically means the game object we collided with, if the tag is equals equals to ground,

19:28.570 --> 19:29.610
as you can see.

19:29.650 --> 19:36.530
Then what we're doing, we're just setting a bag ground parameter to true means we are setting it to

19:36.570 --> 19:40.410
true means we're gonna able to jump for the next time as well.

19:40.410 --> 19:44.820
So we're just accessing and we checking if the game object has a tag called ground.

19:44.820 --> 19:46.340
So we're going to collide with this ground.

19:46.340 --> 19:50.900
Then what we're doing we're just sitting back is ground parameter to true as you can see.

19:51.460 --> 19:55.140
And uh so we will able to jump for the next time.

19:55.380 --> 20:01.060
Uh, and then after making our player jump, uh, we just setting back is ground parameter to false.

20:01.180 --> 20:06.820
And as soon as we go colliding with the ground, then we're setting uh is ground parameter to true.

20:07.020 --> 20:12.300
So as soon as this player GameObject gonna collide with this ground, then we're just setting his ground

20:12.300 --> 20:13.500
parameter to true.

20:13.500 --> 20:19.740
And once we making our player game object jump for the next time, then we setting A is ground to false.

20:19.740 --> 20:24.980
And as soon as this player game object is gonna collide with this ground for the next time, that is

20:24.980 --> 20:26.100
ground parameter.

20:26.140 --> 20:27.260
Just gonna be true.

20:27.300 --> 20:31.540
Means we're gonna able to jump as soon as we're gonna collide with this ground.

20:31.580 --> 20:36.460
Basically, that is the thing, and we're going to press down Ctrl s in order to save our script.

20:36.460 --> 20:38.340
And let's move to unity by now.

20:38.460 --> 20:41.950
So as soon as this player came out to collide with this ground?

20:41.990 --> 20:48.670
You will able to see this player GameObject gonna just gonna be able to jump uh, as well for the next

20:48.670 --> 20:49.070
time.

20:50.110 --> 20:53.590
So let's click on this play button in the top in order to see that.

20:55.590 --> 21:00.670
So as soon as this player GameObject just going to collide with this ground, then this player GameObject

21:00.670 --> 21:01.950
just gonna able to jump.

21:01.950 --> 21:03.070
As soon as it jump.

21:03.070 --> 21:05.270
We just sending back is ground to false.

21:05.430 --> 21:11.630
So as you can see we are only able to jump once this player GameObject just uh, standing on this ground.

21:11.630 --> 21:15.430
So I'm going to click on this pause button in the top in order to pause my game.

21:15.430 --> 21:18.950
And I want to make our player jump a little bit high.

21:18.990 --> 21:21.710
So I'm going to select my player GameObject in the hierarchy.

21:21.710 --> 21:26.030
And I'm going to set the jump height in our player script, something like uh ten.

21:26.030 --> 21:32.470
And now if I just click on this pause button in order to just unpause the game, we can see player is

21:32.470 --> 21:35.590
jumping a lot, but we're not able to jump in the air.

21:35.710 --> 21:40.840
We only able to jump as soon as this player GameObject just colliding with this ground.

21:40.880 --> 21:41.880
As you can see.

21:41.880 --> 21:43.480
So I'm going to get out of play mode.

21:43.480 --> 21:50.360
So I hope you get the idea that how you can make your player jump by using a bool parameter and collision

21:50.360 --> 21:58.720
function in unity in with C sharp script, and we can see the jump height just set back to four.

21:59.080 --> 22:03.840
Uh, and we just set it in ten while we, we are in play mode.

22:03.840 --> 22:07.600
So make sure you just autoplay mode and then you can just paste the value.

22:07.600 --> 22:08.960
So it's going to be saved.

22:08.960 --> 22:14.480
So whatever you're going to do inside play mode while you are while you're just playing your game,

22:14.480 --> 22:15.600
it's not going to be safe.

22:15.600 --> 22:21.200
So make sure you just autoplay mode and then you just paste the number once again there.

22:21.360 --> 22:26.720
So in my case I'm going to make the player jump something like ten and make sure you also go to overrides

22:26.720 --> 22:28.000
in top of Inspector.

22:28.040 --> 22:30.200
Then click on this apply all.

22:30.200 --> 22:36.840
So the changes you made in in in this player shape in hierarchy it's just going to be save in this player

22:36.880 --> 22:39.160
GameObject prefab as well.
