WEBVTT

00:00.120 --> 00:05.760
So if we just go ahead and then click on this play button and you will notice as soon as we're going

00:05.760 --> 00:10.560
to right click that, uh, that uh, vector UI just gonna pop up.

00:10.680 --> 00:12.560
So just wait a little moment.

00:12.760 --> 00:19.840
And we don't want to do that when once we click a right mouse button instead, uh, we gonna do in a

00:19.840 --> 00:20.960
different way.

00:21.120 --> 00:22.160
So let me show you.

00:22.160 --> 00:28.160
So if I right click, as you can see, as soon as we clicked right, uh, on our keyboard, sorry.

00:28.560 --> 00:33.440
Uh, right click mouse button, we can see this victory us gets pop up.

00:33.640 --> 00:40.960
So we don't want that to happen instead of, uh, clicking right, uh, right mouse button where if

00:40.960 --> 00:46.360
we at the end of the level, then we just want to win, uh, win our game.

00:46.360 --> 00:52.760
And we just want to bring up this victory UI to do that, let's get out of play mode and we're gonna

00:52.760 --> 00:54.120
open up our script.

00:54.120 --> 00:56.920
So for that, uh, let's remove firstly.

00:57.160 --> 01:03.910
So once we click right click our mouse button which is bringing bringing up our victory UI, which we

01:03.950 --> 01:04.510
don't want.

01:04.510 --> 01:09.510
So we're gonna remove that line of code and we're doing inside our player scape.

01:09.510 --> 01:11.750
So let's head over to this hierarchy.

01:11.790 --> 01:14.550
Let's select our player game object in the hierarchy.

01:14.750 --> 01:17.150
And let's go to player skip in the inspector.

01:17.150 --> 01:20.550
And let's double click on it in order to open that up.

01:20.790 --> 01:27.350
So if I just move over to my update function in the bottom, I can see that if we clicking the right

01:27.390 --> 01:30.950
mouse button, then we just triggering our victory UI.

01:30.990 --> 01:32.630
Basically we just bringing up.

01:32.750 --> 01:34.910
So we don't want to do this.

01:34.910 --> 01:37.230
So that's why we're gonna remove this.

01:37.230 --> 01:39.430
So let's remove that instead.

01:39.430 --> 01:41.950
We're going to do a in a different way.

01:42.150 --> 01:45.270
And now we're going to press down Ctrl S to save our script.

01:45.270 --> 01:47.230
And now let's move over to unity.

01:47.510 --> 01:50.550
So we want a flag at the end of the level.

01:50.710 --> 01:57.390
And if our player GameObject trigger with that flag or collide with that flag, then we just want to

01:57.390 --> 01:59.470
bring up our victory UI.

01:59.670 --> 02:06.830
So just wait a moment and of course I will have the assets in the resources you can download.

02:06.870 --> 02:10.550
Also, you can also you're gonna get some links.

02:10.630 --> 02:13.150
Uh, you can check that out as well.

02:13.670 --> 02:18.190
So just wait a moment and we need to drag our flag sprite.

02:18.590 --> 02:19.950
So just wait a moment.

02:20.550 --> 02:24.870
So now the compilation is done completely.

02:24.870 --> 02:27.830
So let's head over to this project tab assets.

02:27.870 --> 02:30.670
And I'm going to move over to my sprites folder.

02:30.830 --> 02:35.230
As you can notice I have the sprite sheet of the flag right over here.

02:35.230 --> 02:36.710
So I'm gonna select that.

02:36.710 --> 02:38.110
Let's go over to Inspector.

02:38.110 --> 02:43.270
Let's click on this open Sprite editor so we can see we have more than one.

02:43.270 --> 02:47.350
So sprite mode we're going to leave it to multiple and pixel per unit.

02:47.350 --> 02:49.430
We're going to choose something around 16.

02:49.670 --> 02:54.590
And to get rid of blur we're going to choose point of filter filter mode to point filter.

02:54.710 --> 02:59.620
And after doing all of these things click on this apply button in the bottom right.

02:59.660 --> 03:03.700
As soon as we clicked on it, we can see the blurry is gone by now.

03:03.860 --> 03:05.980
And now we need to slice individually.

03:05.980 --> 03:11.500
So let's click on this slice in the top left in our Sprite Editor tab.

03:11.500 --> 03:16.340
And we're going to select a type to uh automatic to create by cell count.

03:16.460 --> 03:22.220
And let's count how many columns and rows we have so we can see one row and five columns.

03:22.220 --> 03:26.340
So we're going to put five columns sorry uh five columns and one row.

03:26.380 --> 03:27.980
Let's click on this slice.

03:27.980 --> 03:30.500
And then let's click on this apply button.

03:30.500 --> 03:31.500
And now it's done.

03:31.500 --> 03:34.060
And I'm going to select my game view once again.

03:34.060 --> 03:36.060
And let's go over to that sprite sheet.

03:36.060 --> 03:40.180
And then click on this arrow in order to see the individual.

03:40.180 --> 03:41.740
So I'm going to select the first one.

03:41.740 --> 03:43.860
And let's drag it over to this in view.

03:44.340 --> 03:49.940
And let's move it somewhere around here I guess this is pretty much fine.

03:51.580 --> 03:55.180
And uh, let's call it uh, something like flak.

03:55.380 --> 04:03.210
So I'm going to call this one a flag, and I'm going to select my flag, and I'm going to drag it in

04:03.210 --> 04:06.410
the top of my hierarchy so I can see all the time.

04:06.610 --> 04:09.410
And let's add some components to this flag.

04:09.450 --> 04:10.170
Game object.

04:10.210 --> 04:12.850
First thing I'm going to add a rigid body 2D.

04:12.850 --> 04:14.570
And I will set it to kinematic.

04:14.570 --> 04:16.850
So it's not going to fall down at all.

04:17.050 --> 04:19.330
So let's click on this add component.

04:19.610 --> 04:22.330
And let's add a rigid body 2D.

04:22.770 --> 04:30.650
And let's set the body body type to kinematic and collision detection to continuous interpolate to interpolate

04:31.330 --> 04:32.970
to making out smooth.

04:33.250 --> 04:40.410
And we're gonna add one more thing which is which will be a box collider 2D for collision detection.

04:41.250 --> 04:43.570
So let's click on this add component.

04:43.570 --> 04:46.090
And we're gonna add a box Collider 2D.

04:46.290 --> 04:54.490
And let's click on this Edit Collider to edit the collider as the size of our flag game object something

04:54.490 --> 04:55.210
like this.

04:55.530 --> 04:58.530
And we're going to check this is trigger to true.

04:58.570 --> 05:06.050
Basically we just want to enable and we don't want our player register uh the register to pass through

05:06.050 --> 05:06.650
this flag.

05:06.650 --> 05:07.490
So that's why.

05:07.810 --> 05:13.010
So our player easily can pass through this flag and it's gonna check with trigger.

05:13.010 --> 05:14.930
So we just check this trigger.

05:14.930 --> 05:19.290
So we're going to check with our trigger on trigger enter 2D function.

05:19.330 --> 05:25.130
Basically once our player GameObject just gonna trigger with this flag or just gonna collide, then

05:25.130 --> 05:28.450
we just want to bring up our victory UI.

05:28.730 --> 05:35.050
But now let's leave it like this and let's make the animation by now, uh, to make the animation right

05:35.050 --> 05:36.370
away, we do know that.

05:36.370 --> 05:38.530
So let's go over to that sprite sheet.

05:38.530 --> 05:44.810
So so select click on this arrow and select the first uh to the end one by holding down shift.

05:44.810 --> 05:50.730
Basically select all of the sprite by holding down shift and then drag it over to the flag GameObject

05:50.730 --> 05:51.530
in the hierarchy.

05:51.570 --> 05:57.040
Top of this black flag GameObject in the hierarchy, so it's going to make the animation right away.

05:57.320 --> 06:01.560
And now we have to choose a folder where we want to place the animation.

06:01.560 --> 06:03.840
So we will go to top lib assets.

06:03.880 --> 06:07.240
And then we will move over to our animation folder.

06:07.480 --> 06:11.560
And we will move over to our other animation subfolder.

06:11.680 --> 06:15.400
So we created those folder to just keep our project clean.

06:15.640 --> 06:17.000
And now we have to name it.

06:17.000 --> 06:24.600
Or you can create a separate folder as well separate subfolder by right clicking then new and then you

06:24.640 --> 06:25.440
a new folder.

06:25.440 --> 06:28.960
And you can name that folder to something like flag animation.

06:29.160 --> 06:34.600
But I'm gonna just place my flag animation animation right over here.

06:34.600 --> 06:35.960
So I'm going to leave that.

06:35.960 --> 06:44.200
So let's call this animation clip to something like flag a flag, underscore animation like that.

06:44.200 --> 06:46.040
And let's click on the save button.

06:46.360 --> 06:51.520
And once we done and if we select our flag then move over to animation tab.

06:51.520 --> 06:53.360
And then click on this play button.

06:53.430 --> 06:58.190
As you can notice, it's playing the flag animation over a can and a can.

06:58.230 --> 07:00.470
So basically this is fine by now.

07:00.870 --> 07:06.870
And what we want to do, we want to tag this flag as a flag tag because we're going to check with a

07:06.870 --> 07:07.470
trigger.

07:07.470 --> 07:14.470
So we basically want to check if this player game object trigger with this flag game object flag game

07:14.510 --> 07:17.510
object that we want our victory UI.

07:17.750 --> 07:21.790
So we just want to specify this flag as a flag game object.

07:21.790 --> 07:25.430
So this player game object know that this is our flag.

07:25.430 --> 07:28.190
And we need to bring up our victory UI.

07:28.230 --> 07:29.070
So that's why.

07:29.310 --> 07:32.510
So we're going to select our flag GameObject in the hierarchy.

07:32.550 --> 07:34.350
Then go over to Inspector Tag.

07:34.390 --> 07:36.870
As you can notice it says tag.

07:36.990 --> 07:40.990
So just click there and then click on this attack in the bottom.

07:40.990 --> 07:42.710
Then click on this plus icon.

07:42.710 --> 07:44.870
Name the tag whatever you want.

07:44.870 --> 07:47.350
So I'm going to name it something like flag.

07:47.350 --> 07:52.670
And then click on the save button and make sure you select your flag GameObject in the hierarchy one

07:52.670 --> 07:53.310
more time.

07:53.470 --> 07:55.030
Then go over to Inspector.

07:55.070 --> 07:57.110
As you can notice, it says untagged.

07:57.110 --> 08:01.630
So let's click on it and let's assign with the tag which we recently created.

08:01.630 --> 08:05.550
And now as you can notice we assign it this flag as a flag.

08:05.590 --> 08:07.750
Game object sorry flag tag.

08:07.790 --> 08:10.270
As you can notice in the inspector.

08:10.390 --> 08:13.070
And now let's turn this flag into a prefab.

08:13.070 --> 08:15.030
So we're going to have the copy of it.

08:15.070 --> 08:21.750
If we lost somehow missed missed mistakenly then we can just restore it directly.

08:21.750 --> 08:25.950
So that's why we're going to make this one a prefab basically copy of it.

08:25.950 --> 08:28.350
So we're going to select our flag in the hierarchy.

08:28.590 --> 08:32.790
And let's drag it over to this prefabs folder in our project tab.

08:32.830 --> 08:34.790
Now we turn it into a prefab.

08:35.310 --> 08:38.630
And what we're going to do now we're going to open up our player skip.

08:38.630 --> 08:45.190
But before I do I'm going to drag my player game object right over here for testing purposes only.

08:45.430 --> 08:48.270
So I'm going to select my player GameObject in the hierarchy.

08:48.470 --> 08:51.540
And let's press down F in order to focus on it.

08:51.540 --> 08:57.860
And let's select the move tool in the scene view and let's move it at the end of the level, this player

08:57.900 --> 09:04.300
game object, uh, let's move it, uh, somewhere over here.

09:04.500 --> 09:06.260
And this seems pretty much cool.

09:06.540 --> 09:10.900
So we can just test the game right away, or we can check it right away.

09:11.220 --> 09:15.580
And now what we need to do, we need to use Ontriggerenter 2D function.

09:15.580 --> 09:17.660
So let's select our player game object.

09:17.660 --> 09:22.020
And let's open up our player script in Inspector by double clicking on it.

09:22.780 --> 09:27.460
And what we're going to do now we're gonna move over to Ontriggerenter 2D function.

09:28.180 --> 09:30.700
Uh, so we have it over here.

09:30.900 --> 09:35.540
And if you haven't included, then type this Ontriggerenter 2D function.

09:35.540 --> 09:38.740
And you can ignore this line of code right over here.

09:38.740 --> 09:41.220
Or you can ignore this if condition.

09:41.220 --> 09:43.460
So what we're going to do right over here.

09:43.460 --> 09:46.580
So this function get called when we trigger with something.

09:46.580 --> 09:49.140
And we can extract information.

09:49.140 --> 09:52.850
What we trigger it with by going over to this collision parameter.

09:52.970 --> 10:00.690
So what we want to check if we trigger with a game object has a tag called flag that we want to, we

10:00.730 --> 10:03.970
just want to trigger our victory UI.

10:04.050 --> 10:07.770
Basically we want to win our game.

10:08.810 --> 10:11.410
So that's why we're going to check right over here.

10:11.610 --> 10:13.290
So let's use this if condition.

10:13.290 --> 10:16.090
Let's make first bracket and some curly brackets.

10:16.090 --> 10:17.970
And what we want to check over here.

10:17.970 --> 10:21.890
We basically want to check if the game object has a tag called flag.

10:22.050 --> 10:26.090
So we will go to collision collision dot game object.

10:26.330 --> 10:28.890
And we're going to access dot tag.

10:28.930 --> 10:32.810
And we will check if the tag is equals equals to our flag.

10:32.810 --> 10:35.250
And make sure you do inside quotation.

10:35.250 --> 10:38.330
And also make sure you're spelling it correct.

10:38.490 --> 10:43.450
So collision dot game object basically basically means the game object we trigger it with.

10:43.530 --> 10:48.850
So if this player game object trigger with this flag then collision dot game object they are basically

10:48.970 --> 10:54.810
means this flag game object and what we're doing, which is accessing the tag of it, as you can notice.

10:55.010 --> 10:57.850
And we're checking if it's equals equals to flag.

10:57.890 --> 10:59.090
As you can see.

10:59.090 --> 11:02.370
So we definitely gonna trigger with this flag game object.

11:02.370 --> 11:05.130
And this flag game object has a tag called flag.

11:05.130 --> 11:09.330
And we can notice in inspector means we just triggering with this.

11:09.330 --> 11:10.610
Then what we want to do.

11:10.650 --> 11:12.730
We just want to win our game.

11:12.930 --> 11:17.010
For now we're gonna print out a message if it's working or not.

11:17.010 --> 11:19.970
So for that, we're gonna move over to our script.

11:19.970 --> 11:25.970
And over here we just want to print out a message for now, for printing out message, we're going to

11:26.010 --> 11:27.610
type this debug.log.

11:28.130 --> 11:29.450
Uh debug.log.

11:29.610 --> 11:34.010
And in, uh, in quotation we can say whatever we just want to say.

11:34.250 --> 11:39.570
Let's say something like victory, a victory, and let's close that up with semicolon.

11:39.570 --> 11:42.890
And we're going to press down Ctrl S to save our script.

11:43.010 --> 11:47.330
And now let's move over to unity a unity editor.

11:47.330 --> 11:49.160
And let's have a look on this.

11:49.520 --> 11:55.080
So as soon as we're going to trigger with this flag game object, you will able to notice the message

11:55.080 --> 12:01.800
just going to pop up in the console says victory since we just printing out that that message only.

12:02.000 --> 12:03.640
So let's have a look on this.

12:05.680 --> 12:07.000
So just wait a moment.

12:07.000 --> 12:11.760
Once our compilation is done we can just go ahead and check that out.

12:11.960 --> 12:13.960
So I'm going to select my console tab.

12:14.160 --> 12:18.480
And let's click on this play button in the top in order to play our game.

12:18.800 --> 12:20.480
And let's have a look on this.

12:24.840 --> 12:26.720
So just wait a moment.

12:29.160 --> 12:36.480
And now if we just trigger with this flag, as you can notice, as soon as we trigger it with this flag,

12:36.720 --> 12:42.000
the message in our console tab just getting pop up says victory as you can notice.

12:42.160 --> 12:47.270
So instead of printing out this message, we just want to trigger our victory way.

12:47.310 --> 12:50.390
Basically, we just want to bring up our victory.

12:50.470 --> 12:53.150
You as you seen earlier.

12:53.150 --> 12:55.270
So we're going to get out of play mode.

12:55.270 --> 12:59.030
And let's open up our script by double clicking on this message.

12:59.030 --> 13:02.830
So we can just move over to that line of code directly.

13:02.870 --> 13:08.670
Or we can simply select our player and we can double click on this player script in the inspector to

13:08.710 --> 13:10.230
open that line of code.

13:10.470 --> 13:16.030
Or we can simply just double click on this message in order to move over to that line of code.

13:16.190 --> 13:17.830
So let's double click on this.

13:19.110 --> 13:23.750
So what we need firstly we need a reference of that victory UI.

13:24.350 --> 13:30.710
So if we move over to hierarchy then canvas and then go over to victory UI, we have the BG.

13:30.750 --> 13:35.750
And if we press down F on it we can see we have it over here.

13:35.750 --> 13:40.470
So basically we need a reference of this BG, not this victory UI game object.

13:40.470 --> 13:44.470
Basically this BG right over here as you can notice.

13:44.470 --> 13:47.910
So we need a reference, then we can just bring this up.

13:48.230 --> 13:49.870
Uh, so we already have it.

13:49.910 --> 13:51.510
We do know basically.

13:51.630 --> 13:57.590
Uh, basically, uh, if I select my player game object in a hierarchy, then go over to Inspector,

13:57.590 --> 13:59.190
scroll down to player skip.

13:59.230 --> 14:03.030
We can notice we have the victory BG, bg, UI.

14:03.070 --> 14:04.150
As you can see.

14:04.350 --> 14:06.470
So basically we need to call the function.

14:06.470 --> 14:12.710
So whenever we clicking the right mouse button we do know that we just uh calling that trigger victory

14:12.750 --> 14:13.350
key.

14:13.390 --> 14:15.630
Uh we just calling that function.

14:15.630 --> 14:18.790
So we're going to call this function over here by now.

14:18.910 --> 14:21.070
So we're going to double click on this message.

14:21.070 --> 14:25.190
So uh, after printing out message I just want to call the function.

14:25.190 --> 14:29.230
And that function just gonna do the rest thing as we have done it.

14:29.230 --> 14:38.030
So if I scroll down we made that function I guess in the up right over here.

14:38.030 --> 14:42.790
As you can notice, we just, uh, made the function right over here.

14:42.790 --> 14:46.140
So we need to call this trigger victory function.

14:46.140 --> 14:50.420
And this function just gonna do the last thing that we have done earlier.

14:50.420 --> 14:54.140
So now I'm gonna move over to, uh, right over here.

14:54.140 --> 14:55.740
So after printing out message.

14:55.740 --> 14:57.700
So I'm going to leave this message.

14:57.740 --> 15:02.700
After printing out message, I want to bring up that, uh, victory UI PG.

15:02.900 --> 15:06.780
So basically I need to call that function, which is trigger victory y.

15:06.940 --> 15:10.780
So let's call the function over here and then make first bracket.

15:10.780 --> 15:12.860
And let's close that up with semicolon.

15:12.860 --> 15:16.060
And we do know that this function is just going to do the raise thing.

15:16.340 --> 15:19.340
And we're gonna press down Ctrl s to save our script.

15:19.340 --> 15:21.260
And now let's move over to unity.

15:21.420 --> 15:27.380
So as soon as we're gonna trigger with this, uh, flag game object, you will able to notice that BG

15:27.420 --> 15:30.060
just gonna pop up right away.

15:30.260 --> 15:37.780
So just wait a moment and you will notice as soon as we're gonna trigger with this victory, uh, sorry,

15:37.820 --> 15:39.700
this flag game object.

15:40.020 --> 15:43.100
So let's, uh, it's done by now.

15:43.340 --> 15:47.370
So let's click on this play button in the top in order to play our game.

15:47.690 --> 15:49.690
And let's have a look on this.

15:55.370 --> 15:56.730
So just wait a moment.

15:58.010 --> 16:07.610
So now if we trigger with this flag, as you can see, as soon as we trigger it a this basically a victory.

16:07.650 --> 16:12.130
YPG just gets pop up and it just bring up from the bottom.

16:12.410 --> 16:19.090
And but the problem is that if we click on this menu we just going over to basically that's fine I thought

16:19.290 --> 16:21.330
it's not working at all.

16:21.530 --> 16:27.810
So if I just click on this play button, we're playing our game and we can see if we click on this next

16:27.810 --> 16:32.850
button, we're printing out a message in the console say load next level.

16:33.050 --> 16:37.490
So whenever we win this game we don't want to move left and right.

16:37.490 --> 16:40.690
As you can notice, we just moving left and right.

16:40.690 --> 16:44.840
We need to stop doing Once we we win the game.

16:45.280 --> 16:50.760
So what we're gonna do, we're gonna get out of play mode, and we will create a bool parameter to just

16:50.760 --> 16:53.440
keep track of if we win the game or not.

16:53.640 --> 16:59.800
So we will open up our simply player script, or you can create a separate script for it, something

16:59.800 --> 17:00.880
like Game Manager.

17:00.880 --> 17:04.520
You can name that script and you can just create that.

17:04.520 --> 17:06.920
But I'm gonna do inside my player script.

17:06.920 --> 17:10.520
So that's why I'm going to open up player script by double clicking on it.

17:10.520 --> 17:15.880
And let's go to top of our class, uh, right over here.

17:16.520 --> 17:18.960
Uh, let's make the function over here.

17:19.160 --> 17:21.320
And this function doesn't need to be public.

17:21.320 --> 17:23.440
So we're going to make it private instead.

17:23.680 --> 17:30.360
And this will be bool which just gonna keep track or keep track of if, if we win the game or not.

17:30.360 --> 17:39.600
And we're gonna say if is game, uh, a victory, let's say something like victory.

17:40.840 --> 17:45.720
Uh, we can say something like, we own the game.

17:45.720 --> 17:48.440
Something like, let's call it victory simply.

17:48.960 --> 17:50.560
Let's call it victory.

17:51.320 --> 17:51.960
Uh, sorry.

17:52.280 --> 17:55.600
It should be victory is victory.

17:55.800 --> 17:59.840
Or let's, uh, I don't know what it's to call.

18:00.120 --> 18:05.520
Uh, so let's leave it to victory, and let's close that up with semicolon, and I'm gonna move over

18:05.520 --> 18:07.160
to this start function.

18:07.160 --> 18:12.320
So in this start of the game, what I'm going to do I'm going to set victory equal to false.

18:12.720 --> 18:14.360
Victory equal to false.

18:14.360 --> 18:14.800
Why.

18:15.040 --> 18:20.720
Because as soon as we're going to start our game, we're not gonna win our game right away.

18:20.720 --> 18:26.640
So that's why in the start of the game, as you can notice, I just set this victory equal to false.

18:26.640 --> 18:32.080
And this parameter we just created up over here, which is a bool parameter just gonna keep track of

18:32.120 --> 18:34.040
if we win the game or not.

18:34.200 --> 18:39.560
But if we trigger with that flag game object, then what we're gonna do, we're gonna set this victory

18:39.560 --> 18:40.390
to true.

18:40.430 --> 18:40.830
Why?

18:40.870 --> 18:44.870
Because we just own the game and we just trigger it with this flag.

18:44.870 --> 18:46.910
Basically means we own the game.

18:47.190 --> 18:50.470
So what we're gonna do, we're gonna move over to that line of code.

18:50.470 --> 18:56.950
In which line of code we just triggering with that flag so we can see we are doing right over here.

18:57.270 --> 19:00.230
So what we're going to do now, we're going to set our victory.

19:00.750 --> 19:01.230
Sorry.

19:01.950 --> 19:09.430
We will say our victory equal to true because we just trigger it with this flag basically means we just

19:09.470 --> 19:10.870
add and add.

19:13.030 --> 19:14.950
So I really apologize for this.

19:15.230 --> 19:22.870
So we do know that if we if we add the end of the level and if we trigger with this flag basically means

19:22.870 --> 19:24.030
we own the game.

19:24.030 --> 19:26.510
So that's why I just said victory to true.

19:26.550 --> 19:27.950
As you can notice.

19:27.950 --> 19:34.030
So once we own our game, we don't want this player a game object to move left and right.

19:34.070 --> 19:41.500
We just want to stop our player moving left and right and then jumping, doing all of those things.

19:41.500 --> 19:47.140
So what we're gonna do, we're gonna move over to our script and we will go to update function.

19:47.140 --> 19:49.100
Basically, we need to move over to that.

19:49.140 --> 19:55.900
We we basically need to move over to that line of code in which line of code, which is moving right

19:55.900 --> 19:56.580
over here.

19:56.580 --> 20:04.100
As you can see, this movement parameter right over here is for is responsible for moving our player

20:04.140 --> 20:05.180
left and right.

20:05.180 --> 20:08.940
And we can notice we're just moving our player right over here.

20:08.940 --> 20:11.980
As you can notice we flipping our player.

20:12.300 --> 20:13.380
Are we checking.

20:13.540 --> 20:15.420
Are we playing our animation.

20:15.420 --> 20:17.180
We playing attack animation.

20:17.180 --> 20:21.820
Basically all of these things we're doing inside our update function.

20:21.820 --> 20:27.940
So before we do all of the all of these things, we just want to check if we already own the game,

20:27.940 --> 20:32.940
then we don't want to do that like moving left and right or jumping.

20:32.940 --> 20:35.980
So that's why we will go to top of our class.

20:35.980 --> 20:38.260
And before we move or jam?

20:38.380 --> 20:39.780
Jam our player.

20:39.780 --> 20:42.900
We just want to check if we own the game or not.

20:42.900 --> 20:44.660
So we're going to use this if condition.

20:44.660 --> 20:47.420
Let's make first bracket and some curly brackets.

20:47.420 --> 20:49.540
And what we want to check over here.

20:49.540 --> 20:53.220
We basically want to check if we own the game or not.

20:53.220 --> 20:54.140
So we will check.

20:54.180 --> 21:01.620
And we do know that we just created this vector parameter in order to basically to just keep track of

21:01.660 --> 21:03.420
if we win the game or not.

21:03.420 --> 21:11.260
So if victory is equals, equals to true or basically means like if you just leave like this, it basically

21:11.260 --> 21:13.620
means true means we own the game.

21:13.620 --> 21:17.020
Now what we have to do, we need to stop moving left and right.

21:17.020 --> 21:20.980
So inside this curly brackets, basically we need to type this return.

21:21.300 --> 21:23.620
And let's close that up with semicolon.

21:23.620 --> 21:29.340
And we do know that after return, whatever we're gonna do it's not gonna be executed at all.

21:29.380 --> 21:35.460
Basically we will stop moving this player left and right, jumping, playing attack animation and all

21:35.500 --> 21:36.580
of those things.

21:36.580 --> 21:43.970
So before we doing all of this, all of these things, we checking if victory is equals equals to true

21:43.970 --> 21:47.210
or if victory if that is the case, we type in return.

21:47.210 --> 21:52.930
And we do know that after return, whatever we're gonna do, it's not gonna be executed at all.

21:52.970 --> 21:59.290
Basically means our player not gonna move left and right, not gonna play jumping animation clip, not

21:59.290 --> 22:01.890
able to attack once we own the game.

22:01.890 --> 22:03.410
So basically that is the thing.

22:03.410 --> 22:10.450
So I hope you get the idea that why we created this victory parameter in order to keep track of if we

22:10.450 --> 22:17.210
own the game or not, and we just checking with that parameter to do something and I'm gonna move this

22:17.210 --> 22:20.090
over here and this seems pretty much fine.

22:20.090 --> 22:26.330
And if you want to move any line of code anywhere, you can just hold down alt on your keyboard and

22:26.330 --> 22:31.690
you can use up and down arrow key on your keyboard to just move up and down.

22:31.970 --> 22:36.560
And I'm gonna remove this comment from over here as well here.

22:37.000 --> 22:42.800
And we created a player type parameter which is not useful.

22:43.000 --> 22:44.440
So we're gonna remove that.

22:45.200 --> 22:48.840
Let's remove that and we get a pop up.

22:48.840 --> 22:50.960
So let's remove this as well.

22:51.000 --> 22:52.680
Or let's leave that.

22:52.680 --> 22:53.800
It's gonna be fine.

22:54.240 --> 22:56.320
Uh that is bool.

22:56.760 --> 23:01.200
Let's call it is player type as we have it done.

23:01.600 --> 23:05.840
And you can basically ignore these things and it's up to you.

23:05.840 --> 23:07.280
You can ignore that.

23:07.280 --> 23:10.920
And we're gonna press down Ctrl s in order to save our skip.

23:10.920 --> 23:13.080
And now let's move over to unity.

23:13.080 --> 23:20.240
So now, by now, as soon as we're gonna trigger with this flag GameObject, that BG is gonna pop up,

23:20.240 --> 23:26.680
which is victory, and we will unable to move left and right once we win the game.

23:28.000 --> 23:32.280
So just wait a moment and once we done, we can just check that out.

23:32.680 --> 23:36.640
So let's click on this play button in the top in order to play our game.

23:36.640 --> 23:38.520
And let's take a look on this.

23:38.760 --> 23:44.440
So as soon as we're gonna trigger with this flag game object, we will unable to move later.

23:44.440 --> 23:44.840
Right.

23:44.880 --> 23:47.800
Jumping and playing attack animation clip.

23:47.800 --> 23:49.480
So let's have a look on this.

23:49.880 --> 23:52.200
So I'm gonna flag as you can see.

23:52.560 --> 23:57.760
But the problem is that we, we can notice our player is still moving.

23:57.760 --> 24:00.400
So what we're gonna do, we can get out of play mode.

24:00.720 --> 24:06.240
And we just want to set the movement parameter to zero as well as the speed.

24:06.240 --> 24:09.800
So this player game object not gonna move at all.

24:09.960 --> 24:14.240
So what we're gonna do, we're gonna open up our player script by double clicking on it.

24:14.600 --> 24:17.200
And we will go to over here.

24:17.320 --> 24:24.320
So we're doing so what we want to do, we just want to set the movement parameter to zero as well as

24:24.360 --> 24:26.400
we can just set the speed to zero.

24:26.680 --> 24:31.720
So this movement right over here as you can notice it's responsible for moving.

24:32.040 --> 24:34.150
So once we win the game.

24:34.150 --> 24:37.270
We just want to set this movement parameter to zero.

24:37.270 --> 24:40.990
So this player right over here, it's not gonna move at all.

24:41.030 --> 24:42.550
Basically that is the thing.

24:42.910 --> 24:47.070
So before we type return we're gonna set movement equal to zero.

24:47.510 --> 24:49.710
And let's close that up with semicolon.

24:49.710 --> 24:52.590
And we're gonna press down Ctrl s to save our script.

24:52.590 --> 24:54.630
And now let's move over to unity.

24:55.030 --> 24:56.910
And it should be fine by now.

24:57.150 --> 25:02.310
And if it's not working, then we also need to set our move speed to zero.

25:02.310 --> 25:05.430
So, uh, it's not gonna move at all.

25:05.430 --> 25:07.270
So let's have a look on this.

25:07.310 --> 25:13.750
If it's not working, then we also need to set our move speed to zero, so it's not gonna move at all.

25:13.750 --> 25:18.470
Let's click on this play button one more time in the top in order to play our game.

25:18.710 --> 25:20.830
And let's have a look on this.

25:25.670 --> 25:27.030
So just wait.

25:28.390 --> 25:35.100
And if we trigger with this flag, as you can see, uh, which is, uh, stops moving to the left and

25:35.100 --> 25:35.500
right.

25:35.500 --> 25:41.220
And if I press down space key on my keyboard, as you can notice, we not jumping at all.

25:41.380 --> 25:47.620
But if you take a closer look, basically, if I select my player in the hierarchy and press down F

25:47.620 --> 25:54.460
in order to focus on it, we can notice it's playing the running animation clip over again and again,

25:54.500 --> 25:55.900
which we don't want.

25:55.940 --> 26:00.300
We want to play the idle animation clip instead of the running one.

26:00.300 --> 26:03.140
So what we need to do, we need to get out of play mode.

26:03.300 --> 26:08.140
And if we select our player in the hierarchy, then go over to animator tab.

26:08.140 --> 26:10.140
As you can see this run parameter.

26:10.140 --> 26:15.980
We do know that if we set this run parameter to one, it's going to play the running animation clip.

26:16.140 --> 26:22.420
And we do know that if we set this run parameter to zero, it's going to play the idle animation clip.

26:22.420 --> 26:27.740
So once we we win the game we just want to set this run parameter to zero.

26:27.740 --> 26:34.340
So this player is not going to play the running animation clip over again and again, and if you little

26:34.380 --> 26:40.940
bit confused, then you can check out previous lecture where we set up our animation of this player

26:40.940 --> 26:42.780
so you can check that out.

26:42.780 --> 26:47.700
So what we're gonna do and this run parameter right over here is a float parameter.

26:47.860 --> 26:50.100
So basically we need to set that up.

26:50.100 --> 26:51.540
So let's go to script.

26:51.540 --> 26:56.940
So after setting movement to zero we also want to play the idle animation clip.

26:56.980 --> 26:59.900
Basically we need to set that parameter to zero.

27:00.060 --> 27:03.020
So firstly what we will do we will go to animator.

27:03.020 --> 27:07.020
And we do know that we have it reference of this animator component.

27:07.180 --> 27:10.420
And we can check that out over here.

27:10.420 --> 27:11.500
Right over here.

27:11.620 --> 27:15.740
And in the start of the game we just getting the animator component.

27:15.740 --> 27:16.900
As you can notice.

27:16.940 --> 27:19.140
Basically we have the reference of it.

27:19.140 --> 27:21.500
So now we have the animator component.

27:21.500 --> 27:25.820
And we're going to use dot set float function and make this brackets.

27:25.860 --> 27:30.060
Why we using we we using this set float function.

27:30.250 --> 27:34.170
Because this one parameter right over here is a float parameter.

27:34.170 --> 27:36.970
So that's why we need to use this set float function.

27:37.210 --> 27:39.850
And this set float function as a first argument.

27:39.850 --> 27:45.170
It's going to take in quotation the parameter name and make sure you just spelling it correct.

27:45.170 --> 27:46.530
So we can say run.

27:46.850 --> 27:50.490
So in quotation we need to pass the parameter name which is one.

27:50.610 --> 27:54.130
And the second thing comma you need to set the value.

27:54.130 --> 28:02.090
So we do know that if we just set it to zero if we set it to zero, it's going to play the idle animation

28:02.090 --> 28:02.450
clip.

28:02.450 --> 28:02.850
Why?

28:03.010 --> 28:08.410
Because if we move over to unity and select this player GameObject in the hierarchy, then move over

28:08.410 --> 28:09.610
to animator tab.

28:09.850 --> 28:13.690
And from this idle to from run from run to.

28:13.730 --> 28:21.130
If we choose this uh to idle and select this transition and then go over to Inspector and scroll down.

28:21.130 --> 28:24.970
We can see that if run is less than 0.01.

28:24.970 --> 28:30.760
So we do know that if we set this run to zero and zero will be less than 0.1.

28:30.760 --> 28:32.800
So the condition is getting true.

28:32.800 --> 28:35.880
So that's why this idle animation just gonna play.

28:36.040 --> 28:39.520
Because we have chosen that condition as you can notice.

28:39.520 --> 28:42.000
So basically we need to set it to zero F.

28:42.200 --> 28:44.440
And we're going to close that off with semicolon.

28:44.440 --> 28:47.640
And we're going to press down Ctrl S to save our script.

28:47.760 --> 28:49.720
And now let's move over to unity.

28:50.440 --> 28:52.800
And by now it's gonna be fine.

28:52.800 --> 28:54.400
So let's have a look on this.

28:54.400 --> 29:00.480
So as soon as we're gonna trigger with this, uh, flag GameObject, firstly that, uh, just gonna

29:00.480 --> 29:06.440
pop up and this player will stop moving left and right, and then it's gonna play the idle animation

29:06.440 --> 29:08.640
clip instead of the running one.

29:09.120 --> 29:15.040
So now if we just go ahead and then click on this play button, it should be it should work fine.

29:15.040 --> 29:21.800
So just wait a moment and if you bit confused then you can check out, uh, previous lecture where we,

29:22.080 --> 29:27.480
uh, set those animation transition and we created those animation clip.

29:27.480 --> 29:33.840
So now if I just trigger with this flag, as you can see, as soon as we just trigger it, this factory

29:33.880 --> 29:35.280
VG just gets pop up.

29:35.280 --> 29:41.760
And by now we can notice in this in view, our player is now playing idle animation clip over again

29:41.760 --> 29:42.320
and again.

29:42.480 --> 29:47.760
And we can notice in the animator tab as well right over here as you can see.

29:48.000 --> 29:54.200
So I hope you get the idea that how you can do it and we can get out of play mode and what we need to

29:54.200 --> 30:01.120
do, we also need to place our some diamonds and hearts and all of those things.

30:01.320 --> 30:05.440
So we need to do and we're going to do it in the next lecture basically.

30:05.480 --> 30:08.800
Sorry not diamonds basically fruits and this heart.

30:08.800 --> 30:11.120
So we basically need to make the level.

30:11.120 --> 30:13.800
So I hope you get the idea that how you can do it.

30:14.000 --> 30:17.360
And I'm gonna press Ctrl s to save my script.

30:18.360 --> 30:20.280
Sorry not save my script.

30:20.320 --> 30:23.040
Basically the project I want to save.

30:23.040 --> 30:28.240
So make sure you just press down Ctrl s on your keyboard to save your project.
