WEBVTT

00:00.080 --> 00:02.080
Let's, uh, create some traps.

00:02.240 --> 00:04.360
Uh, traps in order to take damage.

00:04.400 --> 00:09.600
So I'm going to move over to my sample scene or the scene in which scene we're playing our game.

00:09.720 --> 00:13.720
So let's head over to this project tab, then assets and then scenes folder.

00:13.720 --> 00:18.560
And I'm going to double click on this sample scene in order to move into that scene.

00:19.000 --> 00:22.600
So I have some uh traps sprites and we can see.

00:23.000 --> 00:27.720
So let's, uh, move over to this project tab, then assets and then sprites folder.

00:27.720 --> 00:30.400
And I have traps folder over here.

00:30.600 --> 00:34.440
And you can see we have the sprites of traps.

00:34.680 --> 00:38.280
Of course I will have a link in the resources of this as well.

00:38.280 --> 00:40.360
So you can go and check that out.

00:40.600 --> 00:43.400
And I'm going to select my player game object in the hierarchy.

00:43.400 --> 00:47.480
And let's press down F on our keyboard in order to focus on it.

00:47.840 --> 00:51.560
And let's go to I'm going to select my this shuriken.

00:51.560 --> 00:54.560
So let's select that and select that sprite sheet.

00:54.560 --> 00:55.760
Then go over to Inspector.

00:55.760 --> 01:00.440
Click on Open Sprite Editor so we can see we have more than one sprite.

01:00.440 --> 01:05.840
So we need to choose this sprite mode to multiple in the inspector, and we're gonna choose a pixel

01:05.840 --> 01:12.440
per unit, something around 16in order to make this, uh, shuriken or this short rap a little bit large

01:12.440 --> 01:15.120
in size, in sprite size.

01:15.360 --> 01:18.800
And to get rid of blurry, we will choose this point filter.

01:18.800 --> 01:22.960
And after doing all of these things, click on this apply button in the bottom.

01:22.960 --> 01:29.440
And as soon as we click apply now we can see the blurry is gone by now and we need to slice individually.

01:30.000 --> 01:34.040
So we will move over to this sprite Sprite editor tab.

01:34.040 --> 01:35.720
In the top left we can see slice.

01:35.720 --> 01:41.280
So just click there and select automatic to create by cell count and count how many columns and rows

01:41.280 --> 01:41.880
you have.

01:41.880 --> 01:47.080
So we can see we have one row and 369 columns.

01:47.080 --> 01:49.760
So we're going to put nine columns and one row.

01:50.360 --> 01:53.400
Uh sorry not nine actually I guess eight columns.

01:53.400 --> 01:55.480
So we have eight columns and one row.

01:55.760 --> 01:58.920
And let's click on this slice and then click on this apply.

01:59.200 --> 02:02.130
And I'm going to select my game view once again over here.

02:02.130 --> 02:07.730
And let's go to that spreadsheet and then click on this arrow in order to see the individual one.

02:07.730 --> 02:09.210
So I'm going to select my first one.

02:09.210 --> 02:14.250
So let's select that sprite and let's drag it over to the scene view or in this hierarchy.

02:14.250 --> 02:16.570
So I'm going to drag it over to my scene view.

02:16.770 --> 02:21.290
And I just want to make it a this uh a little bit uh big.

02:21.410 --> 02:24.090
So what I'm going to do, I'm going to select my sprite sheet.

02:24.130 --> 02:25.570
Let's go to Inspector.

02:25.570 --> 02:30.970
And I'm going to make this pixel per unit a less number, even more smaller than 16.

02:30.970 --> 02:33.690
So this is just going to be big in size.

02:33.690 --> 02:35.850
So I'm going to make it something around 12.

02:35.890 --> 02:38.450
And let's click on this apply button in the bottom.

02:38.450 --> 02:43.650
As soon as we clicked apply we can see by now it's just gets a little bit bigger.

02:43.850 --> 02:48.010
And I'm gonna call I'm gonna say something like uh shuriken.

02:48.010 --> 02:50.050
So I'm going to call it shuriken.

02:50.530 --> 02:56.330
And let's select this and I'm going to drag it top of my hierarchy in the hierarchy so I can see all

02:56.330 --> 02:57.050
the time.

02:57.050 --> 03:00.210
And we will add some components to this story.

03:00.650 --> 03:05.410
First thing we will add a rigidbody 2D and we will set the gravity scale to zero.

03:05.570 --> 03:07.250
Or we will set it to kinematic.

03:07.250 --> 03:10.330
So it's not gonna fall down due to gravity.

03:10.450 --> 03:14.650
And the second thing I will add a collider 2D to this origin.

03:14.650 --> 03:16.130
So it's gonna detect collision.

03:16.130 --> 03:22.890
If this player GameObject collide with this origin, that means our player GameObject need to destroy

03:22.930 --> 03:23.930
right away.

03:24.450 --> 03:27.570
So let's select this origin and let's add some component.

03:27.570 --> 03:29.450
So let's click on this add component.

03:29.450 --> 03:32.050
First thing I'm gonna add a rigid body 2D.

03:32.050 --> 03:34.170
So let's find that component by typing.

03:34.170 --> 03:37.290
And let's hit enter in order to attach that.

03:37.290 --> 03:39.810
And I will set body type to kinematic.

03:39.810 --> 03:41.330
So it's not gonna fall down.

03:41.370 --> 03:44.090
Due to our gravity and collision detection.

03:44.090 --> 03:46.410
We will choose continuous and interpolate.

03:46.410 --> 03:49.810
We will choose interpolate to making a little bit smooth.

03:50.130 --> 03:57.410
And we will add a second thing which is which will be a collider 2D for collision detection.

03:57.410 --> 03:59.490
So let's click on this add component.

03:59.530 --> 04:01.650
And we're going to add a Collider 2D.

04:01.650 --> 04:04.410
So you can add any Collider 2D that you like.

04:04.450 --> 04:08.650
You can go with this box Collider 2D as well as Circle Collider 2D.

04:08.650 --> 04:10.770
But make sure it just fit perfectly.

04:10.770 --> 04:15.490
So that's why we're gonna add a Circle Collider 2D in order to fit it perfectly.

04:15.810 --> 04:21.970
And you can just adjust the radius of this Collider 2D as well by moving over to this radius.

04:21.970 --> 04:25.290
And you can make something around 1.25.

04:25.290 --> 04:27.250
And I'm going to make 1.25.

04:27.250 --> 04:29.210
So this seems pretty much cool to me.

04:29.450 --> 04:31.810
But you can just play around with that.

04:31.810 --> 04:36.690
And I also want to assign this shuriken game object as a drop tag.

04:36.850 --> 04:40.490
So we can see in the inspector tag it says untagged.

04:40.490 --> 04:43.170
So just click there and then click on this add tag.

04:43.210 --> 04:45.290
And we're going to click on this plus icon.

04:45.290 --> 04:48.210
And we will create another tag for this trap.

04:48.210 --> 04:54.610
So I will just going to add we're going to assign this as a this shuriken as a trap tag because I want

04:54.610 --> 04:56.490
to check what we collided with.

04:56.530 --> 04:58.970
If that came out say has a trap tag.

04:58.970 --> 04:59.050
Proptech.

04:59.090 --> 05:02.810
That means we need to destroy our player game object right away.

05:02.810 --> 05:06.010
So that's why I'm going to assign this shuriken as a drop tag.

05:06.050 --> 05:11.490
So let's call it drop and then click on save and make sure you just select that game object one more

05:11.490 --> 05:12.850
time in the hierarchy.

05:12.850 --> 05:14.530
Then go over to Inspector Tag.

05:14.570 --> 05:15.410
It says untagged.

05:15.410 --> 05:18.370
So let's click there and we're going to assign it with drop.

05:18.410 --> 05:22.770
Now we assign it this shuriken as a drop tag so we can just uh no.

05:23.010 --> 05:27.970
And also we need to make the animation, which is just gonna play the circular animation.

05:28.010 --> 05:30.530
It's gonna seems like it's just rotating.

05:30.730 --> 05:36.490
So I'm gonna move over to my project app one more time than assets, and then this, uh, drops folder

05:36.810 --> 05:42.330
and I will select all of these individual sprite by holding down shift and then drag it over to the

05:42.330 --> 05:44.490
shuriken GameObject in the hierarchy.

05:44.930 --> 05:45.970
A hierarchy.

05:45.970 --> 05:48.090
So it's going to make the animation right away.

05:48.090 --> 05:52.410
So we will move over to this assets folder, then animation folder.

05:52.570 --> 05:55.850
And we will move over to this stop animation folder.

05:55.850 --> 06:00.340
And we will create another sub folder for Forth is a trap game object.

06:00.340 --> 06:07.420
So let's right click the new folder and I will name this folder to something like traps animation and

06:07.460 --> 06:08.260
traps.

06:08.620 --> 06:11.100
Traps underscore animation.

06:11.340 --> 06:14.020
So let's call it something like that and hit enter.

06:14.020 --> 06:18.740
And we're going to double click on double click on it to in order to open that up.

06:19.020 --> 06:21.980
And I will name this animation to something like shuriken.

06:21.980 --> 06:24.540
So this is our shuriken or the shot trap.

06:24.540 --> 06:27.220
So I'm going to name it to something like shuriken.

06:27.340 --> 06:29.340
And after that click on the save button.

06:29.340 --> 06:34.100
And now if we select our shuriken in the hierarchy then move over to animation tab.

06:34.100 --> 06:38.060
We can click on this play button in order to see the animation.

06:38.060 --> 06:41.020
And indeed it seems like it's just rotating.

06:41.020 --> 06:43.420
So we just made the animation.

06:43.420 --> 06:44.780
So let's code it.

06:44.780 --> 06:48.220
But before we do, let's make this shuriken game object as well.

06:48.260 --> 06:50.380
A prefab basically means copy.

06:50.580 --> 06:55.780
So let's select the shuriken GameObject in the hierarchy, and let's drag it over to this assets folder

06:55.780 --> 06:57.620
or into this prefab folder.

06:57.620 --> 07:02.300
So I'm going to select my shuriken GameObject in the hierarchy, and I'm going to drag it over to my

07:02.340 --> 07:03.580
this prefabs folder.

07:03.620 --> 07:06.740
Now we just turn it into a prefab, basically a copy.

07:06.780 --> 07:07.900
We have now.

07:08.220 --> 07:12.860
So what we're going to do, we're going to check if this player GameObject collides with this shuriken

07:12.900 --> 07:13.580
at this.

07:13.620 --> 07:18.700
And in if this game object or this shuriken game object has a tag called trap.

07:18.700 --> 07:24.180
And we do know that if we select our shuriken, we can see we assign it this shuriken game object as

07:24.180 --> 07:24.980
a trap tag.

07:24.980 --> 07:30.380
So I'm going to check that means if we if the player game object now collides with a trap tag, game

07:30.420 --> 07:34.540
object means this player game object need to destroy right away.

07:34.540 --> 07:36.660
So we're gonna go, we're gonna code it.

07:36.660 --> 07:39.540
So let's select our player game object in the hierarchy.

07:39.780 --> 07:42.860
And let's open up the player script where we just colliding.

07:42.860 --> 07:47.300
So we're going to double click on this player script in order to open it up in Visual Studio.

07:47.700 --> 07:51.420
And I will move over to my this on collision enter 2D.

07:51.580 --> 07:58.020
So make sure you just type this and you can just ignore this if condition over here you can ignore it.

07:58.300 --> 08:00.740
So make sure you just include this function.

08:00.740 --> 08:04.180
This, uh, private void Oncollisionenter 2D function.

08:04.180 --> 08:07.300
Basically, this function gets called when we collide with something.

08:07.300 --> 08:10.980
So let's suppose this player GameObject collide with this shuriken GameObject.

08:11.300 --> 08:13.340
Then this function over here.

08:13.340 --> 08:18.260
Just gonna just gonna call right away and what we want to check.

08:18.300 --> 08:24.500
And we're going to extract info info about this, what we hit with by moving over to this collision

08:24.500 --> 08:25.220
parameter.

08:25.220 --> 08:30.540
So we're going to use this collision argument over here we have on collision enter 2D function.

08:30.540 --> 08:35.060
And by this parameter we can extract info about what we hit with.

08:35.060 --> 08:41.140
So we can extract info like name of the game object we hit with the tag, even a component that we're

08:41.140 --> 08:41.940
looking for.

08:41.940 --> 08:44.380
So what I'm gonna do I'm going to check over here.

08:44.380 --> 08:47.260
So this function get called when we collide with something.

08:47.260 --> 08:50.340
And we we will check if we collide with that trap.

08:50.740 --> 08:53.060
Uh, trap tag game object or not.

08:53.060 --> 08:53.780
So I'm going to check.

08:53.780 --> 08:59.420
So let's make this if condition first bracket and some curly brackets and what we want to check over

08:59.420 --> 08:59.660
here.

08:59.660 --> 09:02.380
We want to check whatever we collided with.

09:02.420 --> 09:05.300
If that game object has a tag called trap.

09:05.300 --> 09:14.180
So we will go to collision dot object dot tag and we will check if the tag is equals equals to trap.

09:14.340 --> 09:19.620
If that is the case means uh, so basically what we're doing, we do know that once we collide with

09:19.620 --> 09:20.500
this hurricane.

09:20.500 --> 09:23.140
So this function is just going to call out right away.

09:23.140 --> 09:29.100
And what we're doing we're checking if collision dot object dot tag collision dot game object basically

09:29.100 --> 09:31.340
means the game object we collided with.

09:31.340 --> 09:34.460
So we definitely gonna collide with this hurricane game object.

09:34.460 --> 09:39.140
So collision game object right there basically means this hurricane game object.

09:39.140 --> 09:43.940
And then what we're doing we're just going over to shuriken game object and accessing the tag.

09:43.940 --> 09:48.380
And we're checking if the tag is equals equals to trap as you can see.

09:48.380 --> 09:53.660
So basically we're just moving over to this shuriken game object once we collide then accessing the

09:53.660 --> 09:58.190
tag and accessing the tag which is trap as you can see in the inspector.

09:58.590 --> 10:00.710
And we're checking if the tag is equals.

10:00.710 --> 10:01.950
Equals to trap tag.

10:01.990 --> 10:06.030
As you can see over here means we definitely colliding with that.

10:06.030 --> 10:07.270
So we can game object.

10:07.270 --> 10:11.230
So what we need to do now we need to take damage.

10:11.230 --> 10:14.230
So for now I'm going to print out a message in the console.

10:14.590 --> 10:18.910
Firstly we just accessing the tag as you can see of that shuriken game object.

10:18.910 --> 10:22.470
And then we're checking if the tag is equals equals to trap.

10:22.750 --> 10:27.670
And we definitely know we assign it that game object as a trap tag.

10:27.670 --> 10:30.870
So we're checking it over here means we just colliding with that.

10:30.870 --> 10:34.830
So in that moment we need to destroy our player game object right away.

10:34.830 --> 10:40.270
But before we destroy let's print out a message in the console, something like Destroy player.

10:40.270 --> 10:43.710
So in order to print out message we're going to type debug dot log.

10:43.870 --> 10:49.550
And we're going to say something like destroy destroy player.

10:49.790 --> 10:52.270
And now let's close that up with semicolon.

10:52.270 --> 10:55.350
And let's press down Ctrl S to save our script.

10:55.350 --> 10:57.190
And let's move to unity by now.

10:57.470 --> 11:02.510
So whenever we're going to collide with the shuriken GameObject, you will see that message just going

11:02.510 --> 11:08.150
to pop up in the console says Destroy Player because we assign it this shuriken as a trap tag, and

11:08.150 --> 11:12.550
we're checking right there if the tag is equals equals to trap or not.

11:12.590 --> 11:17.470
If it's, then we're just printing out the message in the console says destroy player.

11:17.470 --> 11:19.350
So I'm going to select my console tab.

11:19.350 --> 11:23.990
And let's click on this play button in the top in order to check it and have a look.

11:24.030 --> 11:30.350
And make sure you just make this shuriken GameObject as well a prefab so you can have the copy of it.

11:30.350 --> 11:34.270
Then you can just, uh, place wherever you want.

11:34.310 --> 11:39.230
So as you can see, as soon as we collided with this shuriken, I'm going to click on this pause button

11:39.230 --> 11:41.470
in the top in order to pause my game.

11:41.670 --> 11:47.110
And if we move over to console tab, we can see a message just gets pop up once we collide with the

11:47.110 --> 11:50.630
shuriken GameObject and the message says Destroy Player.

11:50.630 --> 11:55.750
So instead of printing out message what we really want to do, we just want to destroy this player game

11:55.790 --> 11:57.110
object right away.

11:57.110 --> 12:01.790
So when I click on this play button in the top in order to get out of play mode and let's move over

12:01.790 --> 12:02.550
to script.

12:02.550 --> 12:07.910
So instead of printing out message what we will do, we will destroy our player game object.

12:07.910 --> 12:11.070
So what we will do, we're just going to call this type function.

12:11.310 --> 12:15.830
And we already made a function inside this player script as you can see.

12:15.870 --> 12:22.310
And what this function is doing, it's just activating the game over you by then, checking our camera,

12:22.350 --> 12:26.710
then checking this, then showing up the explosion effect as you can see.

12:26.710 --> 12:29.790
So it just doing all of the rest thing that we need to do.

12:29.790 --> 12:33.910
So what we can simply do, we can simply call this type function and die function.

12:33.910 --> 12:38.990
Just going to do all of these things like destroying our player and showing up, the showing up, the

12:38.990 --> 12:42.190
explosion effect and camera check all of these things.

12:42.190 --> 12:43.990
So we're going to call this type function.

12:43.990 --> 12:50.590
And if you haven't met the die function yet then make it as basically create a custom function, call

12:50.590 --> 12:52.270
it die, something like that.

12:52.310 --> 12:57.390
And I'm going to call the function over here once we collide with the trap and we can see we're just

12:57.390 --> 12:58.670
colliding over here.

12:58.670 --> 13:01.070
So we will simply call that type function.

13:01.070 --> 13:04.630
So we will make and we will put the name of the type function.

13:04.630 --> 13:08.230
And let's make first bracket and close that up with semicolon.

13:08.230 --> 13:09.910
Basically we're just calling that.

13:09.910 --> 13:12.870
And now I'm going to press Ctrl s to save my script.

13:12.870 --> 13:14.190
And let's move to unity.

13:14.590 --> 13:20.150
So as soon as we're going to collide with this so we can game object, we will see that the function

13:20.150 --> 13:21.430
just going to call out.

13:21.430 --> 13:27.670
And we do know that what we have done inside that function, we basically destroying our player game

13:27.710 --> 13:30.750
object and doing all of the rest thing that we need.

13:30.910 --> 13:34.950
So I'm going to click on this play button in the top and we will see that.

13:34.950 --> 13:37.950
So just wait a little moment to start our game.

13:37.950 --> 13:40.470
Once it's done we are ready to do that.

13:42.910 --> 13:44.430
So let's collide with this.

13:44.590 --> 13:51.070
Uh, so again as you can see, as soon as we collided, uh, this game over us gets activated.

13:51.070 --> 13:53.870
Camera just gets six as well as our.

13:53.910 --> 13:56.400
We destroyed our player game object.

13:56.400 --> 14:01.800
Basically what we really need to do, and we can just click on this retry button in order to load up

14:01.800 --> 14:05.240
the level one more time or retry the game one more time.

14:05.240 --> 14:07.200
So I'm going to click on this retry button.

14:07.480 --> 14:12.800
And as soon as we just colliding with this hurricane, we're just destroying our player game object

14:12.800 --> 14:17.160
right away as well as just we activating the game over UI.

14:17.320 --> 14:21.360
And we can just click on this menu button in order to move over to Manu.

14:21.560 --> 14:25.240
And we can just click on this play button in order to play our game.

14:25.240 --> 14:27.000
So basically this is the cool thing.

14:27.000 --> 14:28.440
And let's get out of play mode.

14:28.440 --> 14:32.000
And we're going to have multiple uh traps as well.

14:32.160 --> 14:34.120
I have also a fire trap.

14:34.120 --> 14:40.000
And I'm going to drag this, uh, shuriken game object a little bit further away from this, uh, player

14:40.040 --> 14:43.480
game object to testing for testing purposes only.

14:43.480 --> 14:49.120
So I'm going to select my shuriken game object in the hierarchy, and let's select this move tool and

14:49.120 --> 14:50.360
move tool over here.

14:50.680 --> 14:56.680
And I'm going to move it something like this much because I'm going to have the fire trapped by now.

14:56.680 --> 15:03.800
So I will move over to my project app one more time than assets and then sprites folder and traps folder.

15:03.800 --> 15:07.400
I can see I have the fire trap over here, so let's select that.

15:07.400 --> 15:10.680
Go over to Inspector, click on Open Sprite Editor.

15:10.680 --> 15:12.800
So we need to slice it individually.

15:12.800 --> 15:17.360
So we need to choose this sprite mode to multiple in Inspector and pixel per unit.

15:17.360 --> 15:23.520
We're gonna make something around 16 as we have done our coin this heart and this shuriken.

15:23.720 --> 15:29.560
For this shuriken we have chosen 12 but for this fire, I'm gonna choose it something around 16 and

15:29.560 --> 15:32.320
to get rid of blurry, we're going to choose point no filter.

15:32.320 --> 15:34.360
And let's click on this apply button.

15:34.560 --> 15:36.000
And let's click on this slice.

15:36.000 --> 15:40.320
In this Sprite Editor tab we will select automatic to create pixel count.

15:40.320 --> 15:42.880
And let's count how many columns and rows we have.

15:42.880 --> 15:48.080
So we have one row 369 12 columns.

15:48.080 --> 15:51.200
So we're going to put 12 columns and one row.

15:51.200 --> 15:56.280
And after that let's click on this slice and then click on this apply button and I'm going to select

15:56.280 --> 15:57.640
my game view once again.

15:58.280 --> 16:00.760
And let's go to that Fires sprite.

16:00.760 --> 16:04.160
And let's click on this arrow in order to see the individual.

16:04.360 --> 16:06.160
And I'm going to select my first one.

16:06.200 --> 16:08.200
And let's select this one instead.

16:08.240 --> 16:09.520
And I'm going to select that.

16:09.520 --> 16:12.720
And let's drag it over to the scene view or in this hierarchy.

16:12.880 --> 16:15.960
And I'm going to drag this GameObject in the hierarchy top.

16:16.280 --> 16:18.240
So I can see all the time.

16:18.240 --> 16:22.600
And I just want to rename this one to something like Fire Trap.

16:22.920 --> 16:25.160
So let's call it Fire Trap.

16:25.400 --> 16:28.880
And let's add some components to this fire trap as well.

16:28.880 --> 16:33.200
So first thing we will add a rigid body 2D and we will set it to kinematic.

16:33.200 --> 16:36.160
So it's not going to fall down due to our gravity.

16:36.160 --> 16:40.400
So let's go to Inspector then let's click on this add component.

16:40.400 --> 16:43.000
Let's add a component rigid body 2D.

16:43.040 --> 16:45.840
And let's set the gravity body type to kinematic.

16:45.840 --> 16:48.920
So it's not going to fall down due to gravity.

16:48.920 --> 16:51.680
And we will choose collision detection to continuous.

16:51.680 --> 16:54.520
So it will continuously detect any collision.

16:55.120 --> 16:57.280
and also what we need to do.

16:57.800 --> 17:01.520
We can just ignore this interpolate if you just want to make a.

17:01.560 --> 17:07.560
If you just want to make a little a little bit smooth, then you can interpolate to interpolate.

17:07.560 --> 17:13.960
But I'm going to leave that and let's add a one more collider to the component to this Firetrap game

17:14.000 --> 17:14.560
object.

17:14.560 --> 17:18.160
And that will be a collider 2D for collision detection.

17:18.160 --> 17:22.440
So let's click on this add component and we will add a box Collider 2D.

17:22.680 --> 17:27.840
And we will adjust the collider as the size of our sprite game object.

17:27.840 --> 17:29.880
So let's click on this Edit Collider.

17:29.880 --> 17:35.120
And we will edit the collider as the size of our sprite game object.

17:35.560 --> 17:37.720
And you can see that as well.

17:39.640 --> 17:42.120
And this this seems pretty fine now.

17:42.120 --> 17:48.400
And also we want to assign this fire trap as a trap tag because this is our trap and we checking if

17:48.400 --> 17:52.680
we're colliding with this trap then we just destroying our player game object.

17:52.680 --> 17:56.890
So that's why we're going to assign this fire wire trap as well as a trap tag.

17:56.890 --> 18:00.010
So let's go to Inspector then tag and it says untagged.

18:00.010 --> 18:01.410
So let's assign with trap.

18:01.450 --> 18:07.370
Now we so player can know this is our trap and this player game object need to destroy.

18:07.570 --> 18:12.490
And I just want to edit the collider from the right side a little bit inside.

18:12.690 --> 18:14.850
I just want it something like this much.

18:14.850 --> 18:16.930
And this seems pretty much cool.

18:17.130 --> 18:23.570
And once we are done, we can make this one fire trap a prefab in order to make it copy.

18:23.570 --> 18:25.850
But before we do, let's make the animation.

18:25.850 --> 18:30.650
So we will select all of the individual sprite by holding down shift of this fire trap.

18:30.650 --> 18:36.090
And let's drag it over to this Fire Trap GameObject in the hierarchy in order to make the animation

18:36.090 --> 18:36.850
right away.

18:36.850 --> 18:40.570
So I will move over to my assets folder, then animation folder.

18:40.570 --> 18:44.690
I have created this animation folder, so let's open that up.

18:44.690 --> 18:48.490
And I also have traps underscore animation sub folder.

18:48.490 --> 18:50.610
So let's open that up as well.

18:50.810 --> 18:56.450
And I will call this animation to something like Fire trap, so let's call it fire instead.

18:56.450 --> 18:57.970
And let's click on this save.

18:58.170 --> 19:03.570
And if we select our Fire Trap GameObject in the hierarchy, then move over to the animation tab.

19:03.570 --> 19:07.130
We can just click on this play button in order to see the animation.

19:07.130 --> 19:08.370
Now as you can see.

19:08.370 --> 19:10.010
So this seems pretty much cool.

19:10.010 --> 19:13.010
And let's make this fire trap a prefab by now.

19:13.010 --> 19:18.730
So I'm going to select my Fire Trap game object in the hierarchy, and let's drag it over to this prefabs

19:18.730 --> 19:22.370
folder in our assets folder in this project tab.

19:22.410 --> 19:24.170
Now we just made a prefab.

19:24.330 --> 19:28.330
So if I just I'm going to move this one somewhere over here.

19:28.930 --> 19:31.250
And let's click on this play button.

19:31.250 --> 19:38.290
And you will see as soon as we're going to collide with this fire trap that we will destroy our player

19:38.330 --> 19:42.090
game object, because we assigned this fire trap as a trap tag.

19:42.090 --> 19:44.490
And we do know we just talking about it.

19:44.650 --> 19:50.610
And as soon as we collide it, we can see we're just calling the die function and die function just

19:50.610 --> 19:51.570
doing the right thing.

19:51.570 --> 19:53.170
So I'm going to get out of play mode.

19:53.170 --> 19:57.810
So what we basically have done, we just assign it this fire trap as a trap tag.

19:57.850 --> 20:03.730
As you can see in Inspector and we do know which is only checking trap tag means if we just colliding

20:03.730 --> 20:07.370
with any trap tag game object, we just calling the die function.

20:07.370 --> 20:13.970
And you can notice over here as well if the game object has a tag called trap, and we do know we assign

20:13.970 --> 20:17.850
it this shuriken as well as this fire trap as a trap tag.

20:17.850 --> 20:25.010
So player, just knowing that this is our trap as well as well as this shuriken as a trap.

20:25.010 --> 20:26.250
So that is the reason.

20:26.250 --> 20:29.370
But the problem is that I don't want to activate this box.

20:29.370 --> 20:35.210
Collider 2D once this fire stops are popping out from this thing.

20:35.450 --> 20:41.050
So if I select my fire trap game object, then move over to animation tab and we can just move this

20:41.130 --> 20:42.650
frame in order to see it.

20:42.650 --> 20:48.490
So as you can see, edges are basically what we what it's basically doing.

20:48.490 --> 20:50.130
It's just making our fire.

20:50.370 --> 20:56.250
So I, I only want to activate this box Collider 2D of this Fire Trap GameObject.

20:56.250 --> 21:04.690
Once it's just making out the fire out once it's just uh, you can say once the fire just getting activate.

21:04.690 --> 21:08.330
So at that moment I'm going to enable this box collider to 2D.

21:08.490 --> 21:16.130
But once, uh, the this file is not getting out, then I'm gonna disable this box Collider 2D so this

21:16.130 --> 21:22.250
player GameObject can easily pass through it, or else we, uh, we will die as soon as we're gonna

21:22.250 --> 21:23.850
collide with this, uh, fire.

21:23.850 --> 21:27.570
So by default, I just want to deactivate this, uh, fire game.

21:27.610 --> 21:31.090
Uh, this box Collider 2D of this fire trap game object.

21:31.090 --> 21:33.690
So this player game object can easily pass through it.

21:33.690 --> 21:39.930
But once this, uh, this thing just, uh, making our fire, then at that moment, I'm just gonna activate

21:39.930 --> 21:41.370
this box Collider 2D.

21:41.370 --> 21:43.290
So it will just gonna detect collision.

21:43.290 --> 21:47.370
So basically that is the thing or the logic that we need to understand.

21:47.370 --> 21:50.770
So by default, we're gonna disable this box Collider 2D.

21:50.810 --> 21:52.890
We don't want this to be activate.

21:52.940 --> 21:59.260
And once it's just making our file, then I'm gonna deactivate that file box.

21:59.260 --> 22:00.060
Collider 2D.

22:00.060 --> 22:02.140
So by default, we're gonna deactivate.

22:02.140 --> 22:04.860
So let's select the file trap game object in the hierarchy.

22:04.900 --> 22:08.500
Let's go to Inspector and I'm gonna uncheck this box Collider 2D.

22:08.500 --> 22:10.460
Basically we just disabling it.

22:10.460 --> 22:14.180
And now we're gonna move over to this animation tab of this fire trap.

22:14.180 --> 22:18.900
And something over here, we're gonna we're gonna activate our box Collider 2D.

22:19.060 --> 22:21.100
I guess this should be pretty much fine.

22:21.820 --> 22:28.780
So what we can simply do, uh, we we're gonna activate the fire, uh, I guess over here.

22:28.780 --> 22:30.980
So this are just gonna be perfect.

22:30.980 --> 22:33.860
So in this moment, we need to activate that box.

22:33.860 --> 22:38.460
Collider 2D because it just making our fire and this player game object.

22:38.500 --> 22:44.100
If it's collide now, then we're just gonna destroy our player game object.

22:44.100 --> 22:49.900
So let's go to animation tab and make sure you just hit this red button in order to capture the animation.

22:49.900 --> 22:54.580
So in this moment we're gonna activate our box Collider 2D component.

22:54.580 --> 22:56.020
So let's go to Inspector.

22:56.060 --> 22:58.660
Then let's enable this box Collider 2D.

22:58.700 --> 23:01.300
Or we just need to check in order to enable.

23:01.300 --> 23:08.420
And over here we need to disable this something like over here we need to disable the box Collider 2D

23:08.460 --> 23:12.460
because it's not making out fire at all in this moment.

23:12.460 --> 23:13.820
So we're gonna disable that.

23:13.820 --> 23:17.380
So let's go to Box Collider 2D and we will uncheck that.

23:17.380 --> 23:25.060
So if we just make our if we just click on this play button in our animation tab we can see this box

23:25.060 --> 23:28.740
Collider just getting activate once it's making our fire.

23:28.740 --> 23:33.740
And once it's not making fire then it just we just deactivating the box.

23:33.740 --> 23:34.820
Collider 2D.

23:34.820 --> 23:38.140
So this player game object can easily pass through this time.

23:38.140 --> 23:41.140
Once the box Collider 2D is disabled.

23:41.140 --> 23:42.580
So that is the thing.

23:42.620 --> 23:45.740
And I also want what I basically want to do.

23:45.780 --> 23:49.460
I just want to move all of these frames a little bit further away.

23:49.460 --> 23:53.780
So player gonna have enough time in order to pass through this file.

23:53.780 --> 23:55.340
So basically that is the reason.

23:55.340 --> 24:01.300
So make sure you just hit this red button to record your animation as it's not going to be recorded.

24:01.300 --> 24:03.860
So make sure you just do that in animation tab.

24:04.100 --> 24:09.220
And I'm going to select I think from this we're going to select all of this frame and let's drag it

24:09.220 --> 24:13.060
away something like over here which is one second.

24:13.220 --> 24:17.100
So we're gonna have enough time in order to pass through this fire trap.

24:17.100 --> 24:24.060
And we can just click on this play button now so we can see we have a little bit time in order to deactivate

24:24.060 --> 24:25.260
or activate this box.

24:25.260 --> 24:26.260
Collider 2D.

24:26.260 --> 24:31.580
So player gonna have the time that it can easily pass through this fire trap game object.

24:31.740 --> 24:36.980
And once you are satisfied with the animation, then you can just hit this red button to capture the

24:36.980 --> 24:37.740
animation.

24:37.740 --> 24:39.540
Or you can just leave it like that.

24:39.580 --> 24:42.540
It's automatically gonna capture the animation.

24:42.540 --> 24:48.220
And let's have a look on this, and I'm gonna move my fire trap something over here and make sure you

24:48.220 --> 24:52.180
just go to overrides in the inspector and then click on this apply all.

24:52.740 --> 24:54.140
So this is fine by now.

24:54.460 --> 24:57.820
And let's click on this play button in the top in order to see it.

24:58.100 --> 25:00.020
And we're gonna have a look on it.

25:02.460 --> 25:06.020
I hope you get the idea or the logic that we need to do so.

25:06.020 --> 25:08.620
We basically need to move a little bit further away.

25:08.620 --> 25:14.180
So we're gonna have a little bit time and we can see indeed once we just, uh, passes through that

25:14.180 --> 25:18.300
fire trap once, uh, this fire just not making out.

25:18.660 --> 25:20.700
So we just have the enough time.

25:20.700 --> 25:22.180
I hope you get the idea.

25:22.180 --> 25:23.780
And I'm gonna get out of play mode.

25:23.780 --> 25:30.780
And also, we need to do one more thing is that once our player is, uh, down something over here,

25:30.780 --> 25:34.660
it's not landing on top of this ground, and it just passes through it.

25:34.660 --> 25:35.340
Something.

25:35.380 --> 25:37.860
Let's suppose the player is over here.

25:37.900 --> 25:39.740
Means player just gonna fall down.

25:39.900 --> 25:41.060
Uh, to the.

25:41.300 --> 25:46.500
You can see in the down direction, it means we need to destroy our player game object right away.

25:46.660 --> 25:50.140
Once the player game object somewhere in the bottom over here.

25:50.140 --> 25:51.220
Something like that.

25:51.220 --> 25:53.310
So we can note the position as well.

25:53.310 --> 25:56.310
So I'm going to select my player game object in the hierarchy.

25:56.790 --> 25:59.190
So let's do it over here.

25:59.190 --> 26:01.430
So let's select the player game object in the hierarchy.

26:01.430 --> 26:04.070
And let's press down F in order to focus on it.

26:04.070 --> 26:11.110
And we can just measure the y axis or the position that we're just going to call it die point.

26:11.430 --> 26:16.430
So if I just move this player game object something in the Y somewhere over here.

26:16.430 --> 26:20.870
So this position is just a perfect time in order to destroy this player game object.

26:20.870 --> 26:27.190
Because as you can see, once the player is over here, it's not gonna make able to jump on top of this,

26:27.350 --> 26:28.470
uh, tile gram.

26:28.470 --> 26:31.190
So we need to destroy this player game object once.

26:31.190 --> 26:37.630
It's just falling down somewhere over here in the Y, and we can just go over to Inspector, then transform.

26:37.630 --> 26:44.630
And in the y axis, we can see the position which is minus, uh, I guess -1.8 just gonna be perfect

26:44.670 --> 26:46.430
time or minus two simply.

26:46.430 --> 26:48.430
So minus two we're going to check for.

26:48.430 --> 26:54.190
So if the position of this player game object in the y axis minus two means we need to destroy this

26:54.190 --> 26:58.510
player game object, because it's not going to be able to jump on top of that ground tile.

26:58.510 --> 26:59.830
So that is the reason.

26:59.830 --> 27:00.870
So let's do that.

27:00.870 --> 27:03.550
So we're going to select our player game object in the hierarchy.

27:03.550 --> 27:06.590
And let's open up the player script by double clicking on it.

27:06.590 --> 27:09.150
And let's move over to our update function.

27:09.150 --> 27:09.990
Over to this.

27:09.990 --> 27:14.190
Because update function runs every single frame and every single frame.

27:14.190 --> 27:21.670
We just want to check of our position, uh, check our position, uh, position of that player game

27:21.710 --> 27:22.110
object.

27:22.110 --> 27:24.510
So we're going to do it over here something like that.

27:24.510 --> 27:29.030
So we will check if and let's make some curly brackets and what we want to check.

27:29.030 --> 27:32.590
We just want to check y position of that player game object.

27:32.590 --> 27:35.750
So we will check transform dot position dot y.

27:35.790 --> 27:41.470
So transform dot position dot y basically means current position of that player game object in the y

27:41.470 --> 27:41.990
axis.

27:41.990 --> 27:47.430
So basically we're just going over to this uh Inspector sorry, we're moving over to this transform

27:47.430 --> 27:53.510
of this player, then moving over to this position and accessing this y axis, as you can see.

27:53.550 --> 28:00.350
And we will check y axis of that player game object if it's lesser than or equal to something like minus

28:00.350 --> 28:07.310
two f as we check and we do know minus two f, just gonna be something over here means right now what

28:07.310 --> 28:07.950
we need to do.

28:07.990 --> 28:10.110
We need to destroy this player game object.

28:10.150 --> 28:15.270
Because this player game object not gonna able to jump on top of this tile crown once the player game

28:15.310 --> 28:18.390
object is over here in the y axis.

28:18.910 --> 28:22.790
So what we will do in this situation we're going to call the die function.

28:22.790 --> 28:24.870
And we do know what die function is doing.

28:24.870 --> 28:26.750
It just destroying our player.

28:26.750 --> 28:30.070
And we have the die function in the bottom as you can see.

28:30.070 --> 28:32.790
So let's do that or let's call it over here.

28:32.830 --> 28:38.150
Once our player position in the y axis is lesser than or equal to minus two f.

28:38.150 --> 28:40.230
So let's call the die function over here.

28:40.230 --> 28:41.430
And let's make first bracket.

28:41.470 --> 28:43.350
Let's close that up with semicolon.

28:43.350 --> 28:46.070
And we're going to press Ctrl S to save our script.

28:46.070 --> 28:47.550
And let's move to unity.

28:47.550 --> 28:54.950
So we're just taking our player position in the y axis, A or A or basically that means transform dot

28:54.990 --> 28:55.430
position.

28:55.470 --> 29:02.270
Dot y basically means current position of this player game object in the y axis y axis, and we are

29:02.270 --> 29:05.390
checking if that is lesser than or equal to minus two.

29:05.430 --> 29:10.030
F means we are just calling the die function and die function just doing the rest thing.

29:10.030 --> 29:11.590
So let's go to unity now.

29:11.590 --> 29:15.790
And I'm gonna move this player somewhere over here to check.

29:15.790 --> 29:17.710
So in the y axis we're going to check.

29:17.710 --> 29:21.150
So let's click on this play button in the top in order to check it.

29:22.350 --> 29:28.070
And we will see once whenever this player game object in the y axis just gonna be uh, something like

29:28.070 --> 29:34.430
-2 or 0.2, you will see this player game object just gonna destroy itself right away.

29:34.830 --> 29:37.070
So just let's have a look on this.

29:37.870 --> 29:40.030
Uh, so let's take a look.

29:41.590 --> 29:45.950
So just wait a little bit moment, and we're going to check that.

29:49.510 --> 29:50.070
Sorry.

29:50.560 --> 29:53.160
uh, what I'm gonna do instead, I'm gonna.

29:53.360 --> 29:57.960
I'm gonna select my player game object, and I will move this over here.

29:57.960 --> 30:03.760
So this player game object just gonna just gonna fall right away for testing purposes.

30:03.760 --> 30:09.520
I only have done it or just moved this player game object over here, and now we will check it.

30:09.520 --> 30:11.720
So let's click on this play button in the top.

30:11.720 --> 30:17.800
And as soon as this player game object in the y axis just gonna be lesser than or equal to minus two,

30:17.840 --> 30:21.560
you will see this player game object just gonna die right away.

30:21.720 --> 30:22.440
So let's see.

30:22.880 --> 30:29.120
And as soon as the player game object is over here basically in the y axis which is minus two, we can

30:29.120 --> 30:34.520
see, uh, our player game object dies and this game over UI just gets activated.

30:34.560 --> 30:38.960
Basically we just calling the die function and die function just doing that thing.

30:38.960 --> 30:43.320
So I'm gonna get out of play mode and I will move this player game object over here.

30:43.320 --> 30:45.800
So let's select the player game object in the hierarchy.

30:45.960 --> 30:47.000
And I'm gonna move it.

30:47.000 --> 30:48.160
Something over here.

30:48.160 --> 30:50.800
And this seems pretty much fine by now.
