WEBVTT

00:00.040 --> 00:05.560
So what we're gonna do now, uh, we're gonna import in our project Lean Twin.

00:05.600 --> 00:06.760
We're gonna import that.

00:06.760 --> 00:08.120
So how we can do that?

00:08.120 --> 00:13.960
For that, we will head over to google.com and make sure you go to Unity Asset Store.

00:14.120 --> 00:16.760
And in the top bar, search Lean Twin.

00:16.960 --> 00:20.800
And once you get it right over here I have it.

00:20.800 --> 00:25.040
So right click on it and then click on this open link in new tab.

00:25.600 --> 00:27.720
So it's gonna open up in a new tab.

00:27.720 --> 00:32.320
You're gonna see a button something over here add to my assets.

00:32.320 --> 00:33.440
So just click there.

00:33.440 --> 00:37.880
And once you're gonna click on it you're gonna see this open in unity.

00:37.880 --> 00:40.120
So just click there in the top bar.

00:40.320 --> 00:43.600
Uh we get a pop up says Open Unity Editor.

00:43.600 --> 00:50.120
So just click on this Open Unity editor and it's going to take you to this unity editor.

00:50.360 --> 00:54.840
So for uh, for that you will be something over here package manager.

00:55.040 --> 00:56.400
And then link to it.

00:56.440 --> 00:57.320
Let me show you.

00:57.480 --> 01:00.760
So you will be right over here Lane.

01:00.800 --> 01:01.560
Twain.

01:02.200 --> 01:02.480
Lane.

01:02.520 --> 01:02.800
Twain.

01:02.800 --> 01:07.520
So search there or it's going to take us directly to Lynn Twain.

01:07.520 --> 01:09.440
So just wait a little moment.

01:09.640 --> 01:15.840
And once we just, uh, download it, we're just going to import in our project.

01:16.040 --> 01:17.960
So just wait a little moment.

01:18.920 --> 01:24.920
Uh, it's it's going to depend upon how much internet your internet speed is.

01:25.240 --> 01:30.920
So as you can see, you're going to see a download button, something over here or a install button.

01:31.320 --> 01:32.520
Uh, so just click on it.

01:32.520 --> 01:35.520
And once you were done then click on this end project.

01:35.520 --> 01:38.080
Uh, basically you're going to see an import button.

01:38.080 --> 01:39.040
Then click on it.

01:39.040 --> 01:41.640
And in the bottom right you can see import.

01:41.640 --> 01:46.280
So just click on it and it's gonna import link to it in your project.

01:46.280 --> 01:50.040
So since I already done it so I'm gonna cut this tab by now.

01:50.320 --> 01:56.760
And if we move over to our project tab assets we can see a new folder which says Lane Twin.

01:56.760 --> 02:03.160
And we have all of the script inside this lean twin to just make cool animation, that's why.

02:03.600 --> 02:10.480
So now what we're going to do, we're going to drag this BG or this BG basically in the bottom we don't

02:10.480 --> 02:12.200
want in the start of the game.

02:12.200 --> 02:19.280
So if I just go add and then click on this play button, you will able to notice it will be centered

02:19.280 --> 02:20.680
in our game view.

02:20.840 --> 02:27.640
So we don't want this this big BG BG by default in the start of the game.

02:27.640 --> 02:31.840
We do want once our player game object loses all of his health.

02:32.080 --> 02:35.320
So as you can see we able to notice this.

02:35.360 --> 02:38.840
We can click on this retry button and this menu button.

02:38.840 --> 02:43.880
And we don't want this to be to be active by default.

02:43.880 --> 02:45.520
So when I get out of play mode.

02:45.520 --> 02:48.880
And for that we will head over to hierarchy then canvas.

02:49.000 --> 02:51.640
And then we're gonna select this game over UI.

02:52.120 --> 02:54.920
Then underneath over here we have the BG.

02:55.080 --> 02:59.690
So make sure you select the BG not the a game over game object itself.

02:59.690 --> 03:03.650
So we're going to select our page and select the move tool in the scene view.

03:03.650 --> 03:05.050
And let's move it down.

03:05.210 --> 03:12.490
Something over here in the way we're gonna move it something -1002 hundred.

03:12.530 --> 03:16.290
As you can notice in Inspector something over here.

03:16.690 --> 03:23.410
And we want to get this once our player game object just dies or loses all of his help.

03:23.570 --> 03:27.850
So we need to open up our player script where we are doing it.

03:27.850 --> 03:30.650
So I'm going to select my player GameObject in the hierarchy.

03:30.970 --> 03:33.850
Let's open up the player script where it's dying.

03:33.850 --> 03:38.450
So we're going to double click on it in order to open that up in Visual Studio.

03:39.410 --> 03:42.730
And it's going to take a few moments to open that up.

03:42.970 --> 03:46.650
And once we open up, we can just scrape that.

03:46.650 --> 03:53.250
So just wait a moment or we can simply create a separate script for that as well.

03:54.810 --> 03:56.290
So just wait a moment.

04:00.690 --> 04:02.210
So just wait a moment.

04:02.210 --> 04:05.770
And once it's done, we can just go ahead and check that out.

04:12.210 --> 04:15.410
So make sure you import in your project lint twin.

04:15.650 --> 04:20.490
Of course I will have in the resources on this or in the source code.

04:20.650 --> 04:22.250
You can check that out.

04:22.530 --> 04:23.570
So just wait a moment.

04:23.570 --> 04:28.250
It's gonna take a few moments, uh, depending upon on your system.

04:28.250 --> 04:33.330
If you do have a fast system, then in your case, it might take around few seconds.

04:33.570 --> 04:40.170
But if you do have a slow system, then in your case, it can take up to two minutes, something like

04:40.170 --> 04:40.610
that.

04:41.450 --> 04:45.930
Uh, so my system is slow, so that's why it's taking a lot of time.

04:46.410 --> 04:50.610
And we're going to move over to our player script where a player is dying.

04:51.130 --> 04:55.010
So if we move over to player Skip and scroll down to the bottom.

04:55.010 --> 04:56.730
We made a dive function.

04:57.370 --> 04:59.970
And over here, as you can notice.

04:59.970 --> 05:02.170
So we just made the dive function.

05:02.170 --> 05:08.530
So what we need to do we need to destroy our player game object when it loses all of his health.

05:08.530 --> 05:15.450
So we only printing out this message says this dot GameObject dot name plus type basically player type.

05:15.570 --> 05:21.370
And after that we just want to destroy our player and to destroy it, we're going to use this destroy

05:21.410 --> 05:22.010
function.

05:22.250 --> 05:29.050
So let's use this destroy and destroy and this destroy function as a first argument.

05:29.050 --> 05:32.330
It's going to take the game object that we want to destroy.

05:32.530 --> 05:34.650
So we're going to pass this game object.

05:34.650 --> 05:38.090
And this dot game object basically is just referencing itself.

05:38.090 --> 05:40.210
Basically the player game object itself.

05:40.490 --> 05:47.330
And if you do want to destroy your player game object after some period of time, then as a comma you

05:47.330 --> 05:50.210
can put the time as a second argument.

05:50.210 --> 05:53.650
Since I want to destroy my player game object right away.

05:53.650 --> 05:57.250
So that's why I'm not gonna put any second condition.

05:57.250 --> 05:59.170
And let's close that up with semicolon.

05:59.170 --> 06:02.170
And we're gonna press down Ctrl s to save our escape.

06:02.170 --> 06:03.970
And now let's move over to unity.

06:04.290 --> 06:10.330
So as soon as we're gonna lose all of our health, we will able to notice our player GameObject just

06:10.330 --> 06:12.770
gonna destroy itself right away.

06:13.850 --> 06:15.170
So just wait a moment.

06:16.490 --> 06:19.930
And we also need to create a script called Game Manager.

06:19.930 --> 06:25.290
And it's just gonna keep track of if the player game object is die or not.

06:25.330 --> 06:33.890
And we're gonna make a game over UI script, game over UI script to just, uh, to just get this in

06:33.890 --> 06:38.530
the center once our player GameObject dies or loses all of his health.

06:38.530 --> 06:45.370
So just wait a little moment and once it's done, we can check that out, but we're gonna get some error.

06:45.370 --> 06:48.890
So let's see if we get some error or not.

06:48.890 --> 06:51.850
And we can see player died, as you can notice.

06:52.010 --> 06:56.290
And if we move over to console tab, we're not getting any error.

06:56.290 --> 06:58.050
It basically means it's fine.

06:58.050 --> 06:59.730
So we're going to get out of play mode.

06:59.850 --> 07:03.170
And what we're gonna do now we're going to bring that up.

07:03.170 --> 07:10.290
So once our player GameObject destroyed itself we want the game over UI screen right over here basically

07:10.290 --> 07:10.970
that big.

07:11.170 --> 07:15.730
So to get that, uh, we can we need to grab the reference of this BG.

07:15.970 --> 07:23.450
So if I select, uh, if I move over to Hierarchy canvas and then game over and select this BG and press

07:23.450 --> 07:25.810
down F in order to focus on that.

07:25.850 --> 07:28.010
We want this BG to be centered.

07:28.250 --> 07:32.490
So basically A in the Y we just want to put zero.

07:32.490 --> 07:36.970
So it's going to be somewhere around here or in the center of the game.

07:36.970 --> 07:37.970
So we want that.

07:37.970 --> 07:40.250
So we need a reference of this BG.

07:40.290 --> 07:41.770
Then we can do that.

07:41.770 --> 07:43.370
So let's grab the reference.

07:43.370 --> 07:45.570
So we will move over to our scape.

07:45.570 --> 07:47.610
And let's go to top of our class.

07:47.610 --> 07:50.370
And let's grab the reference first of it.

07:50.370 --> 07:51.650
So we're going to do it.

07:51.650 --> 07:53.210
Something over here.

07:53.410 --> 07:54.890
So let's give it a title.

07:54.890 --> 07:57.810
So we're going to type this header for our title.

07:57.810 --> 08:00.170
And let's call this one something like UI.

08:00.850 --> 08:07.130
And sorry u I and we need a reference of that game object.

08:07.130 --> 08:12.250
So we're going to make a serialized field sorry serialized field private.

08:12.490 --> 08:15.290
And that BG itself a game object.

08:15.610 --> 08:22.330
So we're going to type game object and we can call this one something like BG or background or bg UI

08:22.570 --> 08:28.650
or Game Over You by as well we can call it, but I'm gonna leave it as BG and we're gonna close that

08:28.650 --> 08:32.730
up with semicolon, and we're going to press Ctrl S to save our script.

08:32.730 --> 08:34.650
And now let's move over to unity.

08:34.970 --> 08:38.330
So underneath our player Skip we will able to notice.

08:38.570 --> 08:42.970
And first thing is uh first thing we will able to notice the title.

08:42.970 --> 08:51.940
And underneath of it we will able to notice that uh basically BG so what we need to do there, we basically

08:51.940 --> 08:54.380
need to drag this page into that slot.

08:54.380 --> 08:55.980
So we will have this widget.

08:55.980 --> 08:58.900
And after that we can just put it in center.

08:59.140 --> 09:04.420
So now what we're going to do if we select our player GameObject in the hierarchy then move over to

09:04.460 --> 09:06.140
Inspector, then player Skip.

09:06.180 --> 09:13.180
In the bottom we can see UI title, and underneath of it we can see BG and it says non game object basically

09:13.220 --> 09:13.740
empty.

09:13.820 --> 09:17.220
So we're going to take our BG underneath our game over UI.

09:17.260 --> 09:20.340
So make sure you select the BG not the game over UI.

09:20.500 --> 09:24.020
So we're going to select that and let's drag it over to that field.

09:24.060 --> 09:27.300
And now we can notice we have the BG basically this one.

09:27.300 --> 09:29.460
Or simply you can call this one.

09:29.460 --> 09:32.500
And now we ready to set this in the Y to zero.

09:32.620 --> 09:36.580
To do that let's open up our player script by double clicking on it.

09:36.980 --> 09:38.180
And what we're going to do.

09:38.220 --> 09:47.020
We're going to move over to our die function where we're dying basically once our sorry, once we loses

09:47.020 --> 09:50.980
all of our health and we want this to be centered in the why.

09:51.180 --> 09:55.340
So I'm going to move over to our die function where we destroying our player.

09:55.700 --> 09:58.660
So in the bottom over here as you can notice.

09:58.660 --> 10:02.020
So before we destroy we just want to set the position.

10:02.020 --> 10:08.140
So we're going to use this BG dot uh dot Lin move.

10:08.420 --> 10:11.140
So we're going to use this Lin move local y.

10:11.300 --> 10:13.140
So make sure you use this.

10:13.140 --> 10:16.100
So firstly we're going over to that BG GameObject.

10:16.100 --> 10:18.140
And we imported Lin tween.

10:18.140 --> 10:20.060
So that's why we able to use this.

10:20.060 --> 10:22.500
So make sure you just use this function.

10:22.500 --> 10:23.980
It's called BG dot Lin.

10:23.980 --> 10:27.420
Move local y and this function as a first argument.

10:27.420 --> 10:33.780
It's going to take the position where we want to uh just want to go or so in the Y.

10:33.780 --> 10:34.540
We want to go.

10:34.540 --> 10:37.460
So that's why we're gonna use this Lin move.

10:37.700 --> 10:40.660
We use this this Lin move local Y.

10:40.860 --> 10:46.300
So in the Y we want to put it zero and zero is just going to be the center basically.

10:46.300 --> 10:52.060
And the second thing, it's going to take the time after how much amount of time you just want to move

10:52.060 --> 10:55.300
your PG in the Y axis to that point.

10:55.420 --> 11:03.180
So after something like 0.8 second and less than one second, and after doing that, make sure you use

11:03.180 --> 11:04.100
this dot.

11:04.180 --> 11:12.820
So get out of the bracket and then use this dot set is so the since we want to use animation.

11:12.820 --> 11:17.060
So that's why we're going to use this set is a set is our pack.

11:17.060 --> 11:19.980
Or you can just use any of them.

11:19.980 --> 11:21.780
It's basically up to you.

11:21.780 --> 11:25.180
So I'm going to use this set is Expo this set.

11:25.220 --> 11:28.980
Sorry out uh let's use this one.

11:29.020 --> 11:33.020
Set is as is sorry set is our pack.

11:33.020 --> 11:36.660
And then make this first bracket and then close that up with semicolon.

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

11:39.500 --> 11:41.340
And now let's move over to unity.

11:41.700 --> 11:49.500
So as soon as our player GameObject just gonna die we just is moving this PG in the Y to zero position.

11:49.500 --> 11:56.340
Basically, in the Y it's going to be zero means A, it's going to be center center of the game, and

11:56.340 --> 12:03.300
it's going to pop up under, uh, basically after 0.8 second and we just use it dot set out back to

12:03.340 --> 12:05.100
just make the animation.

12:05.100 --> 12:07.140
So now let's click on this play button.

12:07.140 --> 12:08.140
Not the animation.

12:08.140 --> 12:09.380
Basically a cool thing.

12:09.380 --> 12:17.380
You can assume it's going to pop up with a cool animation uh, or looping or something like that.

12:17.380 --> 12:24.580
You can simply say, so now what we're going to do, we're going to take damage from this, uh, fire

12:25.020 --> 12:26.100
and this saw.

12:27.180 --> 12:35.260
And as you can see, indeed, as soon as our player GameObject dies, this BG just pop ups with cool

12:35.260 --> 12:36.020
animation.

12:36.060 --> 12:37.700
And let me show you one more time.

12:37.700 --> 12:39.540
So I'm going to get out of play mode.

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

12:44.100 --> 12:45.780
And let's have a look on this.

12:48.380 --> 12:49.820
So just wait a moment.

12:52.860 --> 12:58.300
And what we're going to do, we can see we are taking damages.

12:59.140 --> 13:05.540
And as soon as we're going to lose all of our health, as you can see, indeed it just pop up and it

13:05.540 --> 13:07.860
just pop up with nice animation.

13:07.860 --> 13:13.660
Or you can say with nice transition animation, something like that, you can assume.

13:13.660 --> 13:15.340
So we're going to get out of play mode.

13:15.340 --> 13:21.620
And what we want to do, we want to set this in the start of the game of this PPG position in the start

13:21.620 --> 13:22.140
of the game.

13:22.140 --> 13:28.060
Something over here instead, instead of manually dragging in the bottom side.

13:28.060 --> 13:30.220
As you can see, we already done it.

13:30.260 --> 13:33.700
Instead of doing that, we're going to do it through our code.

13:33.700 --> 13:37.140
So I'm going to move this, uh, BG something over here.

13:37.140 --> 13:42.660
So in the start of the game I'm going to set the position of this BG, something like over here.

13:42.660 --> 13:49.220
So in the Y why, we just want to have the position something like -1002 hundred.

13:49.260 --> 13:52.380
As you saw earlier, as you've seen earlier.

13:52.380 --> 13:53.580
So we're going to do that.

13:53.580 --> 13:57.140
So let's go to script and we will go to start function.

13:57.140 --> 14:00.980
So let's scroll up to the our player script.

14:00.980 --> 14:03.900
And over here we have the start function.

14:03.900 --> 14:06.900
So this start function get call in this start of the game.

14:06.900 --> 14:11.380
So in the start of the game what we want we're going to set the position of that page.

14:11.460 --> 14:18.900
So we will go to page dot transform dot local position dot local position.

14:19.100 --> 14:27.820
And we're gonna set equal to a new Vector3 Vector3 which gonna have x axis y axis and the z axis sorry

14:27.860 --> 14:28.660
z axis.

14:28.660 --> 14:30.860
And then close that up with semicolon.

14:30.860 --> 14:34.180
So what we basically doing we just going over to that PG.

14:34.620 --> 14:41.140
Uh, basically this PG then going over to transform and then accessing the local position and this local

14:41.140 --> 14:45.430
position just gonna going to have x axis, y axis and the z axis.

14:45.430 --> 14:53.150
So that's why we just set equal to a new vector three which which gonna have x axis y axis and the z

14:53.190 --> 14:53.790
axis.

14:54.030 --> 14:58.830
So since we want in the y something in the bottom somewhere around here.

14:58.990 --> 15:08.110
So over here the position is just going to be something like -1500 like that or -1200.

15:08.110 --> 15:14.830
So I'm going to put something like in the Y -1000 1500 F.

15:15.030 --> 15:20.350
And in the, in the Z axis we don't want to change at all anything like that.

15:20.350 --> 15:24.270
So that's why in the Z we're going to put zero F in the x.

15:24.270 --> 15:26.510
We're going to do the same thing zero f.

15:26.510 --> 15:28.390
So we only changing in the y.

15:28.630 --> 15:35.030
So now if I press down Ctrl s on my keyboard and then move over to unity, you will see as soon as we're

15:35.030 --> 15:43.110
going to start our game this BG, BG position, it's just going to be in the Y axis, something around

15:43.110 --> 15:48.230
-1500, as we have done inside that start function.

15:48.230 --> 15:50.790
So just let let's take a look on that.

15:52.150 --> 15:53.630
So just wait a moment.

15:53.630 --> 15:55.070
And now this is fine.

15:55.070 --> 15:57.310
So let's click on this play button in the top.

15:57.310 --> 15:59.470
You will see as soon as our game.

15:59.470 --> 16:00.510
Just gonna start.

16:00.550 --> 16:04.310
This BG will be somewhere over here in the bottom.

16:04.310 --> 16:11.230
But once we're gonna lose all of our health then this BG just gonna pop up with nice animation transition,

16:11.230 --> 16:12.230
something like that.

16:12.750 --> 16:14.670
So let's take damage.

16:14.710 --> 16:21.830
As you can see, as soon as we started our game, this BG just set itself in the Y and we can just go

16:21.830 --> 16:29.510
over to Inspector and we can just take a look of the position, as you can see, which is -1004 hundred,

16:29.550 --> 16:32.750
I guess we have done uh, 1005.

16:33.270 --> 16:33.670
Okay.

16:33.710 --> 16:35.430
So basically that is fine.

16:35.430 --> 16:36.790
It's totally up to you.

16:37.150 --> 16:39.110
Uh, so I hope you get the idea.

16:39.310 --> 16:47.790
And if I just take damage or all of the basically loses all of our health, we can notice it just pops

16:47.790 --> 16:51.230
up right away once we loses all of our health.

16:51.270 --> 16:52.590
As you can notice.

16:52.590 --> 16:58.990
But the problem is that if we click on this retry button and then this menu button, it's doing nothing

16:58.990 --> 16:59.670
currently.

16:59.670 --> 17:05.110
So we need to hook this button with some certain function in order to do some specific things.

17:05.110 --> 17:08.590
So I'm going to get out of play mode and I hope you get the idea.

17:08.790 --> 17:12.510
And I also want this manually to in the bottom.

17:12.510 --> 17:13.670
So it's gonna be clean.

17:13.670 --> 17:14.510
So that's why.

17:14.710 --> 17:20.750
So for that I'm going to head over to my hierarchy, then canvas and then Game Over UI, game object,

17:20.750 --> 17:21.430
then PPG.

17:21.830 --> 17:27.590
And let's move it down somewhere around here and make sure you select your parent game object.

17:27.590 --> 17:31.790
Then go over to Inspector Overrides and then click on this Apply All.

17:32.070 --> 17:34.510
So the changes you made it's going to be save.

17:34.670 --> 17:39.630
And I'm going to press down Ctrl s on my keyboard in order to save my project.
