WEBVTT

00:00.040 --> 00:08.080
Now this player GameObject needs to take damage from this fire trap saw and our spike head that we created

00:08.080 --> 00:09.160
up over here.

00:09.280 --> 00:15.280
Basically, we drag it here as you can notice, and if we select all of these traps, let's suppose

00:15.280 --> 00:21.280
if I select my fire in the hierarchy and then press down F in order to focus on that and go over to

00:21.320 --> 00:21.960
Inspector.

00:21.960 --> 00:26.360
As you can notice, we assign it this fire as a trap tag.

00:26.360 --> 00:33.520
And also if we select our spike head and then go over to Inspector, we can notice we also tag it as

00:33.560 --> 00:34.280
a trap.

00:34.280 --> 00:37.000
And also we have done the same thing with this jaw.

00:37.080 --> 00:43.600
So as soon as this player GameObject just gonna trigger with a GameObject or just gonna collide with

00:43.640 --> 00:50.240
the GameObject has a tag called trap means this player GameObject need to take damage and we already

00:50.240 --> 00:56.640
created player damage and scripting if you haven't checked that out, uh, so you can check out the

00:56.640 --> 00:57.720
previous lecture.

00:57.760 --> 01:03.440
Maybe something like 3130 or 32, even 34, 33.

01:03.480 --> 01:06.000
It can be so you can check that out.

01:06.000 --> 01:08.040
Uh, that uh, scripting part.

01:08.160 --> 01:11.360
Because in there we created the Takedamage function.

01:11.360 --> 01:16.800
So we need to call the Takedamage function once we're gonna trigger with this, uh, trigger with this,

01:16.800 --> 01:19.360
uh, fire trap or this game object.

01:19.360 --> 01:23.480
If we collide with this game object, then we're going to call the function.

01:23.480 --> 01:27.240
So let's open up our player script double by double clicking on it.

01:27.600 --> 01:30.240
And let's go to the bottom of our class.

01:30.480 --> 01:36.840
Uh, you can create a separate script if you do one for your player health, you can do that.

01:36.840 --> 01:39.280
But I'm gonna do inside my player script.

01:39.280 --> 01:44.160
So I'm gonna move over to town somewhere over here, as you can notice.

01:44.160 --> 01:47.480
So we using this on collision enter 2D function.

01:47.680 --> 01:50.720
And this function get called when we collide with something.

01:50.720 --> 01:55.280
But when we gonna trigger with something this function not gonna call at all.

01:55.280 --> 01:57.880
And for that we need to use another function.

01:57.880 --> 02:01.530
And we do know that function is called on trigger.

02:01.730 --> 02:05.050
So we need to include that which is on trigger.

02:05.050 --> 02:07.570
Enter 2D function and this on.

02:07.890 --> 02:10.410
Make sure you just type as I did over here.

02:10.450 --> 02:12.010
Else it's not going to work.

02:12.010 --> 02:16.130
So this on trigger 2D function get call when we trigger with something.

02:16.130 --> 02:19.810
So we're gonna trigger with this uh this fire trap.

02:19.810 --> 02:23.250
So this right over here, it's just going to call right away.

02:23.250 --> 02:27.490
And we can extract information by going over to this collision parameter.

02:27.610 --> 02:33.130
As you can see, we have an argument says Collider 2D and it says collision.

02:33.130 --> 02:36.850
So we can extract information with what we trigger it with.

02:37.050 --> 02:38.890
So what we're going to do over here.

02:39.170 --> 02:45.210
So this function get called when we're going to trigger with uh that fire or any game object that we're

02:45.210 --> 02:46.010
looking for.

02:46.010 --> 02:49.290
So we just want to check the tag of the game object.

02:49.290 --> 02:53.170
If the game object has a tag called trap, then we need to damage.

02:53.170 --> 02:56.890
So before we, uh, damage we just need to check.

02:56.890 --> 02:58.450
So we're going to use this if condition.

02:58.450 --> 03:03.330
Let's make first bracket and some curly brackets and what we want to check over here.

03:03.330 --> 03:05.490
We basically want to check the game object.

03:05.490 --> 03:09.170
We trigger it with hashtag called a trap or not.

03:09.170 --> 03:10.810
So we're going to use this collision.

03:10.970 --> 03:17.330
Collision dot GameObject and collision dot GameObject basically means the GameObject our player trigger

03:17.370 --> 03:18.010
it with.

03:18.010 --> 03:25.290
So the player definitely gonna trigger with this fire as well as this, uh, ground, you can simply

03:25.330 --> 03:30.490
say, so what we want to do now, we just want to access the tag of the game object.

03:30.490 --> 03:31.770
So to access the tag.

03:31.770 --> 03:37.170
So let's type dot tag and we will check if the tag is equals equals to trap.

03:37.370 --> 03:43.130
If that is the case basically means uh, this player game object right over here, it just trigger with

03:43.130 --> 03:44.650
this fire trap.

03:44.650 --> 03:50.370
And now what we have to do, we need to destroy or we need to damage our player.

03:50.370 --> 03:56.730
But before we damage our player, let's print out a message if it's perfectly working or not.

03:56.730 --> 03:58.370
So I'm going to go over to script.

03:58.370 --> 04:02.860
And over here we're going to type a message something like debug dot log.

04:02.980 --> 04:07.020
And we're going to say something like, uh, take player takes damage.

04:07.020 --> 04:11.900
So let's say player takes damage, player takes damage.

04:12.300 --> 04:15.500
And let's close that up with semicolon.

04:15.500 --> 04:18.580
And we're going to press down Ctrl S to save our script.

04:18.580 --> 04:20.460
And now let's move over to unity.

04:20.980 --> 04:25.020
So you will see as soon as beginner trigger with this fire game object.

04:25.020 --> 04:29.860
And we do know that this fire we just assign it with the tag called a trap.

04:29.860 --> 04:31.660
So we just taking that tag.

04:31.740 --> 04:37.380
And if the tag is equals equals to trap then what we simply doing, we just printing out the message

04:37.420 --> 04:38.220
in the console.

04:38.220 --> 04:41.060
As you can notice this player takes damage.

04:41.060 --> 04:46.500
So this message is just going to pop up as soon as we're going to trigger with that fire game object.

04:46.500 --> 04:48.820
So just wait a moment and you will see.

04:49.980 --> 04:51.500
So just wait a moment.

04:53.100 --> 04:58.700
And as soon as we're going to trigger with this fire game object, uh, that uh, that's just going

04:58.700 --> 04:59.300
to pop up.

04:59.300 --> 05:01.780
So let's go to Unity.

05:03.220 --> 05:07.220
And let's click on this play button in the top in order to play our game.

05:07.380 --> 05:10.460
And let's trigger with this fire a game object.

05:10.460 --> 05:17.740
And we do know that we just enabling the fire game object a box Collider 2D once it's flaming up, basically

05:17.740 --> 05:19.980
playing the flame animation clip.

05:19.980 --> 05:25.940
So now if we click closer to fire and if I trigger now it's not calling.

05:25.940 --> 05:32.980
But once the flaming animation is playing and if we move over to console tab, as you can see, the

05:32.980 --> 05:38.020
message just getting pop up says player takes damage as soon as this fire.

05:38.020 --> 05:42.060
Just playing the flaming animation clip animation clip.

05:42.060 --> 05:48.820
Because in that moment we just enabling our box collider 2D of this fire fire game object.

05:48.820 --> 05:50.660
So we're gonna get out of play mode.

05:50.660 --> 05:55.460
So instead of printing out message, we just want to destroy our player.

05:55.700 --> 05:59.340
And we also want to show up some explosion effect.

05:59.380 --> 06:00.900
We're going to do it later.

06:00.900 --> 06:02.380
For now, what we want.

06:02.420 --> 06:07.700
As soon as it's gonna trigger with this trap, we just want to set the position of this player game

06:07.740 --> 06:10.100
object one more time over here.

06:10.100 --> 06:14.580
And also, we need to decrease our max health of this player game object.

06:14.580 --> 06:18.540
So what we will do, we're gonna call we're gonna move over to our script.

06:18.620 --> 06:25.340
So instead of printing out message what we're gonna do, we basically, uh, just want to call the Takedamage

06:25.340 --> 06:28.260
function inside this our player scape.

06:28.260 --> 06:30.060
So we're going to call the Takedamage.

06:30.060 --> 06:33.100
So let's call take damage.

06:33.460 --> 06:34.580
So take damage.

06:34.580 --> 06:37.500
We made it up over here as you can notice.

06:38.260 --> 06:40.060
So we just made it here.

06:40.340 --> 06:41.860
So we need to call the function.

06:41.860 --> 06:44.140
And this function just gonna do these things.

06:44.380 --> 06:48.860
And if you just little bit confused then you can check out previous lecture.

06:48.980 --> 06:51.180
And it may be something like 31.

06:51.180 --> 06:52.420
So check that out.

06:52.460 --> 06:58.460
Uh which I name it something like player health player health or damage scripting.

06:58.460 --> 07:01.510
So you can check out the previous lecture for that.

07:01.510 --> 07:03.950
So now we need to call this Takedamage function.

07:03.950 --> 07:07.310
And this function just gonna do this thing as you can notice.

07:07.310 --> 07:10.430
So let's call the function and this function as a argument.

07:10.430 --> 07:12.870
It's going to take the parameter.

07:12.870 --> 07:14.270
So we're going to pass one.

07:14.270 --> 07:20.590
So every single time we're just gonna are we just gonna lose our health by one unit.

07:20.630 --> 07:23.630
And we're going to press down Ctrl s to save our script.

07:23.630 --> 07:25.630
And now let's move over to unity.

07:25.870 --> 07:31.510
And also you, we need to make a point from where we want to spawn our player.

07:32.070 --> 07:37.350
So just wait a moment and we're going to take a look on that later.

07:37.350 --> 07:40.750
So for a moment let's take a look on this.

07:41.390 --> 07:47.790
So if we just go ahead and then click on this play button in the top in order to play our game.

07:47.790 --> 07:53.550
You will see as soon as we're going to trigger with this fire game object, once this Fire game object

07:53.550 --> 08:00.710
is playing the fire animation clip, this player is just gonna lose all his health by one unit, her

08:00.710 --> 08:02.350
health by one unit.

08:02.390 --> 08:02.870
Sorry.

08:03.150 --> 08:05.310
So if I get closer to.

08:05.350 --> 08:07.630
As you can see, we're losing health.

08:07.630 --> 08:11.030
Then it's became one and then it's became zero.

08:11.230 --> 08:13.470
So we just loses all of our health.

08:13.550 --> 08:17.990
So what we want to do once we lose our health by one unit.

08:18.030 --> 08:22.190
I just want to spawn this player game object over here one more time.

08:22.310 --> 08:24.110
So I'm going to get out of play mode.

08:24.110 --> 08:26.630
And let's click on this play button in the top.

08:26.630 --> 08:31.150
And let's check the position in the y axis of this player game object.

08:31.150 --> 08:37.150
Since we're going to make a spawn point for this player in order to spawn this player game object itself.

08:37.510 --> 08:38.750
So that is the reason.

08:38.750 --> 08:40.230
So we're going to check the position.

08:40.430 --> 08:46.790
So now if I select my player GameObject in the hierarchy, then move over to Inspector Inspector tab.

08:46.790 --> 08:51.910
And as you can notice, the position in the X is 4.6.

08:51.910 --> 08:58.830
You can simply say and in the Y we can see minus three point -1.3.

08:59.070 --> 09:01.720
And in the x .65.

09:01.760 --> 09:06.040
So what we can simply do, we can just right click on this, uh, transform.

09:06.040 --> 09:09.000
And then we can go over to copy in the bottom.

09:09.000 --> 09:12.880
And then we can just copy copy our position.

09:12.880 --> 09:14.120
So let's click on it.

09:14.120 --> 09:17.040
Now we just copy it and we're going to get out of play mode.

09:17.040 --> 09:20.640
And we will create an empty parent empty game object.

09:20.640 --> 09:26.520
And we're going to paste the value uh and we will call something layer something like player position

09:26.680 --> 09:27.160
spawn.

09:27.520 --> 09:28.760
So let's go to hierarchy.

09:28.760 --> 09:30.760
Right click or hit this plus icon.

09:30.760 --> 09:32.760
Let's create an empty game object.

09:32.760 --> 09:35.760
And we're going to name this game object to something like player.

09:36.080 --> 09:44.560
Let's call it player spawn position player spawn position and make sure you go to Inspector.

09:44.560 --> 09:46.200
Right click and reset.

09:46.200 --> 09:48.920
And we can just paste the value in the x.

09:48.920 --> 09:50.880
We can set 4.65.

09:50.880 --> 09:57.720
And in the Y we can set -1.3 since we already copied the position.

09:57.720 --> 10:01.000
So we can simply go over to this transform right click.

10:01.040 --> 10:02.600
Then we will go to paste.

10:02.600 --> 10:04.080
In the bottom you can see.

10:04.120 --> 10:05.960
And then we're going to paste the position.

10:05.960 --> 10:10.840
And as soon as we paste we can notice in the x which is 4.65.

10:10.840 --> 10:15.920
And in the y which is minus one .1.340.

10:16.200 --> 10:17.720
So this seems pretty much cool.

10:18.000 --> 10:21.240
And for this I'm going to choose an icon.

10:21.240 --> 10:25.040
So let's select the player is player spawn position in the hierarchy.

10:25.280 --> 10:29.840
Go over to Inspector and we're going to choose an icon for that something like this.

10:30.160 --> 10:31.920
And this is fine.

10:31.920 --> 10:35.480
And I'm gonna drag it in the top so I can see all the time.

10:35.480 --> 10:39.720
So we also need a reference to our player spawn position.

10:39.720 --> 10:43.360
Then we can spawn our player in this position.

10:43.360 --> 10:45.080
So we will open up our player.

10:45.080 --> 10:50.760
Skip one more time and let's go to take damage function where we're taking damage.

10:50.920 --> 10:55.920
As you can see, we're taking damage right over here and we're shaking our camera.

10:55.920 --> 11:01.810
So once we take damage, we want to set the position of our player to that position, which is player

11:01.810 --> 11:02.810
spawn position.

11:02.810 --> 11:05.250
So we need a reference to that position.

11:05.250 --> 11:05.810
So for.

11:05.850 --> 11:12.050
It what we will do, we will go to top of our class and we're going to make a serialized private.

11:12.170 --> 11:15.770
Uh fill you can simply say so let's make it over here.

11:15.770 --> 11:18.450
So let's make serialized field private.

11:18.770 --> 11:25.610
And the component we're looking for is position means we basically looking for transform which is responsible

11:25.610 --> 11:26.530
for position.

11:26.530 --> 11:28.490
So we're going to pass our transform.

11:28.490 --> 11:31.770
And we can call this something like player spawn position.

11:31.770 --> 11:36.570
So let's call it player spawn position or a position.

11:36.570 --> 11:39.930
Or you can call player spawn point as well.

11:39.930 --> 11:42.090
And we're going to close that off with semicolon.

11:42.090 --> 11:46.130
And now let's move over to that line of code where we're taking damage.

11:46.130 --> 11:49.330
So we're taking damage over here as you can notice.

11:49.330 --> 11:53.330
So we just want to set our player position to that position.

11:53.330 --> 11:59.330
So what we're going to do after checking our camera we're going to set transform dot position and transform

11:59.330 --> 12:03.770
dot position over here basically means this player current position.

12:03.770 --> 12:10.450
And we're going to set the current position equal to our player spawn position spawn position dot position.

12:10.450 --> 12:12.570
And let's close that up with semicolon.

12:12.570 --> 12:16.210
So we're just setting equal to player spawn position dot position.

12:16.210 --> 12:19.050
So we're setting the current position of our player.

12:19.090 --> 12:25.210
When it takes damage we're setting to our player position player spawn position and we accessing the

12:25.210 --> 12:27.050
position as you can see.

12:27.050 --> 12:28.850
So we're just setting the position.

12:29.050 --> 12:33.010
And now what we're going to do we're going to press down control S to save our script.

12:33.010 --> 12:34.850
And now let's move over to unity.

12:35.170 --> 12:38.770
So what we need we need a reference to that position.

12:38.770 --> 12:44.930
So we created a variable underneath our health title as you've seen on top of our class.

12:44.930 --> 12:49.130
So we need to drag our player's spawn position to that field.

12:49.130 --> 12:50.650
So we're going to have the position.

12:50.650 --> 12:52.170
And we can just spawn it.

12:52.210 --> 12:58.530
As you can see, as soon as our player skip gets compiled, we can see player spawn position and it

12:58.530 --> 12:59.770
says None Transform.

12:59.810 --> 13:03.810
So we're going to take our player spawn position and drag it over to that field.

13:03.850 --> 13:09.050
Now, as you can notice, we have the player spawn position and we are ready to spawn it.

13:09.250 --> 13:14.930
And I'm going to take my player spawn position and let's drag it over to this other stuff GameObject

13:14.930 --> 13:19.330
to just keep uh, I just want to keep my hierarchy clean, so that's why.

13:19.650 --> 13:26.010
So make sure you just create an empty parent game object, and you can just drag all of the things there

13:26.010 --> 13:28.410
in order to make your hierarchically.

13:28.410 --> 13:33.050
So I can simply click over here in order to collapse, as you can notice.

13:33.250 --> 13:39.530
And I'm going to take my fire and we're gonna take it to our traps game object.

13:40.170 --> 13:45.690
But for now, let's leave that and let's go ahead and then click on this play button.

13:45.690 --> 13:49.810
You will notice as soon as we're going to take damage, camera will check.

13:49.810 --> 13:56.170
And our player position of this uh, of this just going to set back to our player position, a player

13:56.170 --> 13:59.130
spawn position as soon as we're going to take damage.

13:59.250 --> 14:02.980
So let's get closer to, uh, to this, uh, flame.

14:03.220 --> 14:09.860
So now if we take damage, as you can see, as soon as we just taking damage, we just moving over to

14:09.900 --> 14:11.340
player spawn position.

14:11.340 --> 14:15.340
And if we select our player in the hierarchy, then go over to Inspector.

14:15.340 --> 14:18.060
We can notice the player max cell is now one.

14:18.460 --> 14:23.020
And if we just do for the last time, we can see now.

14:23.180 --> 14:24.980
Now it's, uh died.

14:25.020 --> 14:33.700
As you can see player died message just uh, pops up because once we taking once we losing all of our

14:33.700 --> 14:34.220
health.

14:34.220 --> 14:37.180
Then we just calling the die function and die function.

14:37.180 --> 14:40.780
Just simply printing out this message saying player died.

14:40.780 --> 14:44.620
So I'm going to get out of play mode, and we're gonna check with this.

14:44.700 --> 14:47.540
Uh, stop by now, we're going to check with this.

14:48.020 --> 14:53.300
So let's click on this play button and it's gonna do nothing since we didn't script it.

14:53.300 --> 14:54.940
Our game object.

14:55.340 --> 15:00.060
Uh, so once we're going to collide with this show, then what we want to do, we just want to do the

15:00.060 --> 15:02.780
same thing as we have done with this fire.

15:03.060 --> 15:04.940
So we're just going to take damage.

15:04.940 --> 15:07.620
So let's wait a moment and we're going to surpass.

15:07.820 --> 15:12.700
And if we collide with the shore, as you can see nothing's happening.

15:12.860 --> 15:14.500
So we need to do something.

15:14.700 --> 15:17.500
So what we're going to do we're going to get out of play mode.

15:17.500 --> 15:20.900
And for that we're going to use on collision enter 2D function.

15:20.900 --> 15:21.300
Why?

15:21.500 --> 15:26.980
Because if I select my game object in the hierarchy then go over to Inspector, then Circle Collider

15:27.020 --> 15:27.500
2D.

15:27.540 --> 15:34.060
We didn't check the Is trigger, but if I select my fire then go over to Inspector, then box Collider

15:34.100 --> 15:34.380
2D.

15:34.420 --> 15:36.660
We just check the trigger.

15:36.660 --> 15:41.860
So that's why we're not going to use trigger basically on trigger into 2D function for this.

15:41.860 --> 15:50.180
So instead we're going to use on collision in on collision into 2D function because we added in set.

15:50.340 --> 15:54.260
Sorry if I select my so then go over to Circle Collider 2D.

15:54.300 --> 15:57.460
As you can notice we didn't check the trigger.

15:57.460 --> 16:03.230
So that's why we're going to use the on collision enter 2D function instead of Ontriggerenter.

16:03.230 --> 16:07.790
So we're going to open up our player, skip one more time and let's go to our skip.

16:07.950 --> 16:10.710
And let's go to Oncollisionenter 2D function.

16:10.710 --> 16:14.390
So as you can see I already have it inside my script.

16:14.390 --> 16:17.430
If you haven't then make sure you just type as you.

16:17.470 --> 16:19.030
As I did over here.

16:19.030 --> 16:20.830
And you can just ignore these things.

16:20.830 --> 16:23.590
Or you can just ignore this line of code.

16:23.590 --> 16:24.990
And now what we're going to do.

16:25.350 --> 16:28.230
So this function get called when we collide with something.

16:28.230 --> 16:35.630
And we do know that if we, uh, we just can we can extract information by what we colliding with this

16:35.630 --> 16:36.910
collision parameter.

16:36.910 --> 16:42.190
So we can access access information by going over to this collision parameter.

16:42.190 --> 16:48.950
So what we want to do, we basically want to check if our player GameObject collide with a GameObject.

16:48.950 --> 16:52.070
And if that GameObject has a tag called trap.

16:52.070 --> 16:57.670
So if I say select my shop and then spike head and go over to Inspector.

16:57.670 --> 17:02.070
As you can notice, we just assigned this game object as a trap drop tag.

17:02.070 --> 17:05.230
So we just want to check the check the tag.

17:05.270 --> 17:12.190
If the, uh if the tag is trapped, then that means we need to take damage and we need to set the position

17:12.190 --> 17:14.870
back to our player spawn position.

17:14.870 --> 17:16.110
So we're going to do the same thing.

17:16.110 --> 17:19.910
Basically, we need to call the Takedamage function and Takedamage function.

17:19.910 --> 17:21.510
Just going to do the res thing.

17:21.750 --> 17:23.470
So let's go to our script.

17:23.470 --> 17:24.950
And over here we're going to check.

17:24.950 --> 17:26.550
So let's use this if condition.

17:26.550 --> 17:29.270
Let's make first bracket and some curly brackets.

17:29.270 --> 17:31.110
And what we want to check over here.

17:31.110 --> 17:38.110
We basically want to check if collision dot GameObject dot tag and collision dot GameObject.

17:38.350 --> 17:43.510
Uh collision dot GameObject over here basically means the GameObject we collided with.

17:43.510 --> 17:45.510
So we definitely gonna collide with that.

17:45.510 --> 17:47.590
So GameObject and the spike head.

17:47.630 --> 17:53.230
So collision dot GameObject over here basically means that show or that spike head GameObject.

17:53.350 --> 17:55.110
And then we accessing the tag.

17:55.150 --> 17:56.910
As you can notice dot tag.

17:56.950 --> 18:02.030
And we're going to check if the tag is equals equals to trap if that is the case.

18:02.030 --> 18:08.550
So we firstly going over to that game object means our so our spike head, then we accessing the tag

18:08.550 --> 18:12.110
and we checking if the tag is equals equals to trap.

18:12.150 --> 18:13.390
Now what we have to do.

18:13.590 --> 18:16.910
And now our player game object need to take damage.

18:16.910 --> 18:19.750
So basically we need to call this Takedamage function.

18:19.750 --> 18:21.190
And this take damage function.

18:21.190 --> 18:24.030
Just going to do this thing as you can notice.

18:24.070 --> 18:29.070
First it's gonna subtract our health amount and it's going to check our camera.

18:29.070 --> 18:35.430
And then it's going to set our player position to player spawn position dot position as you can notice.

18:35.430 --> 18:40.150
So when I call the function over here because we're going to collide with that trap game object.

18:40.150 --> 18:42.870
So let's call the Takedamage function over here.

18:43.070 --> 18:44.270
Let's make first bracket.

18:44.270 --> 18:46.390
And let's close that up with semicolon.

18:46.390 --> 18:48.510
And this take damage as a damage amount.

18:48.510 --> 18:50.310
It's going to take an argument.

18:50.310 --> 18:54.790
So if we just put five right away it's gonna lose all of his health.

18:54.830 --> 18:59.870
Since I don't want to lose all of my health in one time.

18:59.870 --> 19:02.560
So that's why as a take damage argument.

19:02.560 --> 19:05.520
I'm just going to pass 1 or 2, something like that.

19:05.520 --> 19:08.520
And now we're going to press down Ctrl S to save our skip.

19:08.520 --> 19:10.480
And now let's move over to unity.

19:11.640 --> 19:18.520
And you will see as soon as we collide with this saw game object or that spike had the game object,

19:18.520 --> 19:25.560
we will lose one of our health, one health, and then the player position just going to set back to

19:25.600 --> 19:29.680
our player spawn position or where we just want to spawn it.

19:29.720 --> 19:33.880
Now our skip just gets compiled uh compiled.

19:34.000 --> 19:38.400
So let's click on this play button in the top in in order to play our game.

19:39.760 --> 19:46.680
So just wait a moment and once the compilation is done we can just go ahead and check that out.

19:47.120 --> 19:48.600
So just wait a moment.

19:50.000 --> 19:52.080
So I'm going to collide with this saw game object.

19:52.080 --> 19:53.160
Just wait a moment.

19:53.160 --> 19:59.280
And if we collide with this saw game object you will see that as you can see, as soon as we collide

19:59.280 --> 20:05.240
it, we just spawn it over here from player's pawn position, and if I select my player GameObject in

20:05.240 --> 20:07.320
the hierarchy, then go over to Inspector.

20:07.360 --> 20:16.840
We can see our player health now is four Maxhealth it was five and we just loses one of one of one health

20:16.880 --> 20:19.240
as soon as we just collided with this.

20:19.240 --> 20:20.360
So our game object.

20:20.360 --> 20:22.680
And now let's check with the spike one.

20:23.240 --> 20:25.400
Uh, we're gonna check with this spike.

20:25.680 --> 20:32.400
Or you can simply assume that even if we collide with collide with this spike GameObject.

20:32.560 --> 20:38.120
Uh, basically just gonna it's just gonna, uh, do the same thing like that.

20:38.120 --> 20:40.520
So now let's do that.

20:40.520 --> 20:41.720
So we're going to check it.

20:41.720 --> 20:43.600
So firstly I'm going to pass through it.

20:43.920 --> 20:45.960
Let's press down space key.

20:46.800 --> 20:48.360
Let's okay.

20:48.760 --> 20:50.080
Sorry okay.

20:50.240 --> 20:52.960
We're just taking damage from that enemy.

20:53.320 --> 20:54.840
And this seems pretty much cool.

20:54.880 --> 20:57.680
Basically it's gonna work fine and that's all.

20:57.680 --> 20:59.960
So I'm gonna get out of play mode, so make sure.

21:00.160 --> 21:05.930
And now we're just gonna make our, uh, hierarchy a little bit, uh, clean, you can say.

21:06.090 --> 21:11.570
So let's create an empty parent object, and we're going to name that GameObject to something like drops.

21:11.570 --> 21:17.530
And we're going to drag all of the tracks from our hierarchy into that GameObject in order to make our

21:17.530 --> 21:18.610
hierarchy clean.

21:18.970 --> 21:20.010
So let's do that.

21:20.010 --> 21:22.170
So for it we're going to go to hierarchy.

21:22.210 --> 21:24.250
Right click or hit this plus icon.

21:24.250 --> 21:26.170
Then create an empty game object.

21:26.170 --> 21:29.570
And we're going to call this GameObject to something like traps.

21:29.570 --> 21:30.890
So let's call it traps.

21:30.930 --> 21:33.330
And let's go over to Inspector Transform.

21:33.330 --> 21:35.570
Let's right click on it and then reset.

21:35.690 --> 21:38.090
And we can choose icon over here.

21:38.290 --> 21:42.970
And now I'm going to select uh the traps which is fire and the shore.

21:42.970 --> 21:45.690
And this spike head by holding down control.

21:45.690 --> 21:49.370
And we're gonna drag it top of this traps GameObject in the hierarchy.

21:49.610 --> 21:51.730
And we can just click over here to collapse.

21:51.730 --> 21:55.050
As you can notice, it's now a lot more cool.

21:55.290 --> 21:59.570
And we can press down control S in order to save our project.

21:59.570 --> 22:02.890
So I hope you get the idea that how you can do this.
