WEBVTT

00:00.080 --> 00:05.320
Let's give some health amount to this, uh, anime two game object in order to take the damage.

00:05.320 --> 00:08.040
So we're going to approach the same way we have done.

00:08.040 --> 00:09.200
So let's do that.

00:09.200 --> 00:15.920
So let's open up the anime two script quickly, and let's go to the top of our class and let's declare

00:15.920 --> 00:20.800
a variable, or let's give it some help to our enemy game object.

00:20.800 --> 00:26.360
So let's make a public that will be int, and we can simply call this one Max.

00:26.800 --> 00:29.440
Uh max health and max health.

00:29.440 --> 00:34.080
And by default I'm going to set uh, something like two unit of health.

00:34.080 --> 00:36.360
And let's close that up with semicolon.

00:36.360 --> 00:39.840
And let's make a function take damage somewhere over here.

00:39.840 --> 00:44.120
And we're going to make that function public because we're going to call this function through another

00:44.120 --> 00:52.440
C script or through another C class, uh, from where our player game object shooting onto that enemy

00:52.440 --> 00:54.520
game object, we're going to call the function there.

00:54.720 --> 00:56.600
So let's make this function public.

00:56.760 --> 00:58.800
And for function we're going to type void.

00:58.800 --> 01:04.350
And we're going to call this function to something like take damage and let's make first bracket or

01:04.510 --> 01:05.790
some curly brackets.

01:05.790 --> 01:08.950
So you can give an parameter or argument over here.

01:08.950 --> 01:10.110
I'm not going to do that.

01:10.110 --> 01:13.750
I'm going to do in a different way, uh over here.

01:13.750 --> 01:17.070
So what I will do, I will subtract from this max health.

01:17.230 --> 01:20.150
So we will go to max health minus equal one.

01:20.150 --> 01:23.950
And then we can close that up with semicolon or simply what you can do.

01:23.950 --> 01:28.990
You can just pass in damage and you can just pass the damage over here parameter.

01:28.990 --> 01:32.470
And you can simply later on replace this with one.

01:32.470 --> 01:34.590
But I'm not going to do that for now.

01:35.030 --> 01:38.910
And uh, so if we call this Takedamage function for the first time.

01:38.910 --> 01:42.270
So the max health by default we have given to, as you can see.

01:42.390 --> 01:43.630
So this one is two.

01:43.670 --> 01:45.670
So two minus one is just going to be one.

01:45.830 --> 01:48.990
And if we call this takedamage function for the second time.

01:48.990 --> 01:50.590
So the max health is now one.

01:50.590 --> 01:53.830
So one minus one is just going to be zero as you can see.

01:53.830 --> 01:58.710
So the max health of our enemy two game object just gonna shrink down to zero.

01:58.870 --> 02:05.870
So once our maxhealth is totally zero zero of this enemy two game object, then we need to stop calling

02:05.870 --> 02:06.550
this function.

02:06.550 --> 02:11.950
Or we need to stop subtracting the max because the max health already gonna be zero.

02:11.950 --> 02:12.750
So that's why.

02:12.910 --> 02:19.750
So before we subtract, we're going to check if max health is less than or is equal to zero means it's

02:19.750 --> 02:22.630
already zero, then we're going to make some curly brackets.

02:22.630 --> 02:25.390
So in this moment we need to stop doing this thing.

02:25.430 --> 02:28.430
Basically we need to stop subtracting our max health.

02:28.430 --> 02:29.870
So we're going to type this return.

02:29.870 --> 02:30.990
And let's close that up.

02:30.990 --> 02:32.070
Semicolon.

02:32.070 --> 02:38.150
And let's make a also a die function in order to destroy our enemy game object.

02:38.150 --> 02:40.430
So we're going to do it something over here.

02:40.430 --> 02:42.830
So let's make a void for function.

02:42.830 --> 02:47.070
And we're going to call this die and make first bracket and some curly brackets.

02:47.070 --> 02:52.670
And what we want to do inside this function we're going to destroy this enemy two game object right

02:52.670 --> 02:53.070
away.

02:53.230 --> 02:54.190
So let's do that.

02:54.190 --> 02:56.300
Firstly I'm going to print out a message.

02:56.300 --> 02:59.700
So I'm going to type this debug dot log and log.

02:59.700 --> 03:03.780
And I'm going to say this dot transform dot name.

03:04.020 --> 03:08.260
And top of that I'm going to add a custom message something like says diet.

03:08.260 --> 03:10.420
And let's close that up with semicolon.

03:10.420 --> 03:14.020
So this dot transform basically means it just referencing itself.

03:14.020 --> 03:17.660
So we're just going over to this meta game object transform.

03:17.660 --> 03:20.740
And by this transform we just accessing the name.

03:20.740 --> 03:23.020
So the name we can see is anime two.

03:23.060 --> 03:25.540
So this is just going to be anime to the name.

03:25.540 --> 03:31.260
And top of that we added a message says diet means anime to anime to diet.

03:31.260 --> 03:35.260
Just gonna uh, just gonna pop up underneath our console tab.

03:35.500 --> 03:39.540
And after that, we're gonna destroy this Army two game object right away.

03:39.540 --> 03:41.900
So for that, we're gonna use the destroy function.

03:41.900 --> 03:43.180
So let's go to script.

03:43.220 --> 03:45.940
After printing out message, we're going to use this destroy.

03:46.180 --> 03:48.980
And it's going to take the game object you want to destroy.

03:48.980 --> 03:50.460
So we're going to destroy itself.

03:50.460 --> 03:54.250
So that's why we're going to pass this dot game object means it's up.

03:54.250 --> 03:56.330
And let's close that up with semicolon.

03:56.330 --> 04:00.130
So we also need to call this this die function and die function.

04:00.130 --> 04:04.130
Firstly it's going to print up the message in the console says I'm too tired.

04:04.130 --> 04:07.970
And after that we just destroying right away as you can see.

04:07.970 --> 04:09.610
So we need to call the die function.

04:09.610 --> 04:16.450
But when we shoot once, our max cell of anime tube game object loses all of his health, or the Maxwell

04:16.450 --> 04:17.530
just became zero.

04:17.570 --> 04:19.250
So then we're going to do that thing.

04:19.250 --> 04:21.010
So let's go to update function.

04:21.610 --> 04:23.890
And update function runs every single frame.

04:23.890 --> 04:28.010
So that's why we're going to do right there every single frame we're going to check the max cell.

04:28.050 --> 04:32.890
We're going to type this if if max health is less than or equal to zero.

04:33.010 --> 04:35.170
And let's make some curly brackets mean.

04:35.170 --> 04:39.930
Now we need to call the die function and die function to gonna do the rest thing.

04:39.930 --> 04:43.450
So let's call the die function here and make and close that up.

04:43.450 --> 04:44.330
Semicolon.

04:44.330 --> 04:47.650
So we're checking the max health of our enemy two game object.

04:47.650 --> 04:53.810
So the max health is already is if the max cell is less than or equal to zero, then we're calling the

04:53.810 --> 04:54.770
die function.

04:54.770 --> 05:00.930
And what die function is doing is firstly printing out the message in the console says enemy two died.

05:00.970 --> 05:01.970
As you can see.

05:02.010 --> 05:06.010
And after that we're just destroying our enemy to game object right away.

05:06.010 --> 05:09.170
And we're going to press down Ctrl S in order to save our script.

05:09.170 --> 05:10.610
And let's move to unity.

05:10.610 --> 05:17.130
So we also need to call the Takedamage function in order to take damage on this enemy two game object.

05:17.130 --> 05:19.610
So we also need to call that Takedamage function.

05:19.610 --> 05:24.930
We just made it, uh, we never calling it so our Maxhealth will not move over to zero.

05:24.930 --> 05:27.530
So that's why we need to call the Takedamage function.

05:27.530 --> 05:34.490
But when we're going to call it once our player GameObject shoot it, shoot on this enemy two game object.

05:34.490 --> 05:36.650
So we're going to do call the function there.

05:36.650 --> 05:37.770
So let's do that.

05:37.770 --> 05:40.850
So going to select our player GameObject in the hierarchy.

05:40.850 --> 05:43.170
And let's open up the player script quickly.

05:43.170 --> 05:45.370
And let's call the function where we're shooting.

05:45.370 --> 05:48.010
So as you can see we're shooting it over here.

05:48.010 --> 05:53.360
If hit info is true row means the ray just really colliding with this anime game object.

05:53.400 --> 05:56.560
Means this anime game object need to take the damage.

05:56.560 --> 05:58.160
So let's call the function here.

05:58.280 --> 05:59.960
Here where we create.

06:00.000 --> 06:03.800
So we created the damage function in this anime two script.

06:03.800 --> 06:05.960
So we're going to move over to this anime two script.

06:05.960 --> 06:11.080
And then we're going to call this Takedamage function when we're shooting on that anime game object.

06:11.080 --> 06:15.120
So let's move over to our player script and let's do it over here.

06:15.120 --> 06:20.600
Because over here the the rage is colliding with our enemy game object.

06:20.600 --> 06:28.600
So when I use this hit info dot game, hit info dot transform, we need to use then get component.

06:28.600 --> 06:36.920
And the component we're looking for is a, uh, is a uh, you can simply say our enemy two script.

06:36.920 --> 06:38.440
So let's pass here.

06:38.480 --> 06:41.880
Enemy two sorry, anime two.

06:42.920 --> 06:43.800
Enemy two.

06:43.840 --> 06:45.360
And let's make first bracket.

06:45.360 --> 06:47.080
And then we're going to call the function here.

06:47.080 --> 06:51.270
So take damage and make and let's close it up with semicolon.

06:51.270 --> 06:57.430
So we do not need to pass any argument over here because there we haven't given any argument.

06:57.430 --> 06:58.230
So that's why.

06:58.350 --> 07:04.190
So what we basically doing we just going over to hit info draw transform and hit info dot transform

07:04.190 --> 07:07.390
basically means the game object that we collided with.

07:07.430 --> 07:12.790
So if we shoot out the ray from this player game object and the ray just hit this enemy game object,

07:12.790 --> 07:16.750
then we just moving over to this enemy game object transform component.

07:16.750 --> 07:22.670
And by this transform we just moving over to this enemy two script, as you can see over here.

07:22.790 --> 07:28.150
And then basically we're just getting the enemy two script or the enemy to C-sharp class, as you can

07:28.150 --> 07:28.470
see.

07:28.510 --> 07:31.470
And from there we're just calling the Takedamage function.

07:31.470 --> 07:36.430
So we're simply going over to this enemy two script and then calling the function this.

07:36.590 --> 07:38.550
We're calling this Takedamage function.

07:38.550 --> 07:41.830
And we do know what we're doing inside this Takedamage function.

07:41.830 --> 07:46.660
We just subtracting from our max health by this amount of unit, as you can see.

07:47.220 --> 07:49.060
So I hope you get the idea.

07:49.060 --> 07:50.940
So now we need to save our script.

07:51.100 --> 07:55.900
So we're gonna move over to player script and let's press down Ctrl s in order to save.

07:55.900 --> 07:57.260
And let's move to unity.

07:57.660 --> 08:03.980
So whenever this, uh, this player game object just gonna shoot on this, uh, anime two game object,

08:04.020 --> 08:06.100
you will see this anime two game object.

08:06.100 --> 08:08.860
Just gonna take the damage right away.

08:08.860 --> 08:10.380
So let's have a look on this.

08:11.340 --> 08:13.860
So I'm going to select my anime two game object.

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

08:16.900 --> 08:19.700
So the max file by default we have given two.

08:19.740 --> 08:23.460
As you can see underneath our anime two script in the Inspector.

08:23.700 --> 08:27.420
So once we, uh, shoot on this anime two game object for the first time.

08:27.420 --> 08:29.460
So the max is just going to be one.

08:29.460 --> 08:31.220
So, uh, so let's have a look.

08:32.260 --> 08:34.660
Okay, so we get an error.

08:34.660 --> 08:36.260
So we need to get out of play mode.

08:36.300 --> 08:42.380
Basically we need to assign this enemy to as a enemy layer because we only checking for that layer.

08:42.380 --> 08:46.380
So if we move to player players escape and we can see we have passed.

08:46.380 --> 08:47.460
What is enemy?

08:47.820 --> 08:53.780
Basically we only checking the enemy layer and we can see if we select enemy two GameObject in the hierarchy

08:53.900 --> 08:55.420
and move over to Inspector.

08:55.420 --> 08:59.980
We can see we have an assignment this enemy to GameObject as a enemy layer.

08:59.980 --> 09:05.140
So and if we select our player GameObject in the hierarchy, then move to player Skip.

09:05.140 --> 09:07.420
We can see what is enemy is chosen.

09:07.420 --> 09:08.540
Enemy means the ray.

09:08.540 --> 09:11.340
Just gonna check only for this enemy GameObject.

09:11.340 --> 09:15.380
So we need to assign this enemy to as well as enemy layer.

09:15.380 --> 09:20.700
So let's select the enemy to GameObject in the hierarchy and the top right we can see layer and it says

09:20.700 --> 09:21.260
default.

09:21.260 --> 09:23.180
So let's assign it with this enemy.

09:23.380 --> 09:25.100
And I'm going to click on this note.

09:25.100 --> 09:28.860
This object only means the parent I only want to change.

09:29.060 --> 09:33.420
And we can see by now we assigned this enemy as enemy layer.

09:33.420 --> 09:36.700
So let's go to Over edge and then click on Apply All.

09:36.700 --> 09:38.820
And now we're going to select our player.

09:38.820 --> 09:40.060
And we can see enemy.

09:40.060 --> 09:41.700
So it should be fine by now.

09:41.700 --> 09:43.370
So let's have a look on this.

09:43.370 --> 09:46.730
So let's click on this play button in the top two able to see.

09:47.290 --> 09:54.610
And we're gonna able to see that this enemy just gonna take the damage right away once we shoot on this

09:54.650 --> 09:55.970
enemy two game object.

09:55.970 --> 10:03.370
So if I select and then shoot and we can see now the enemy two just get destroyed right away.

10:03.410 --> 10:09.690
Once we just, uh, once that enemy game object just, uh, loses all of his health.

10:09.890 --> 10:11.850
As you can see now, it's fine.

10:11.850 --> 10:13.210
I hope you get the idea.

10:13.210 --> 10:16.570
So we're gonna get out of play mode and what we want to do.

10:16.650 --> 10:22.330
So once we shoot on this enemy game object, we're gonna spawn the floating tags, as we have done with

10:22.330 --> 10:23.370
the first enemy.

10:23.370 --> 10:27.410
So we're gonna do the same thing in this enemy two game object as well.

10:27.610 --> 10:28.490
So let's do that.

10:28.490 --> 10:32.850
And also once our enemy two game object loses all of his health.

10:32.850 --> 10:38.330
So before it get destroyed, we're gonna show up the explosion effect as well.

10:38.330 --> 10:39.170
So let's do that.

10:39.170 --> 10:44.280
So we're going to do the same thing as we have done with the first anime or anime one.

10:44.280 --> 10:45.120
So let's do that.

10:45.120 --> 10:47.120
So let's open up our anime script.

10:47.120 --> 10:50.800
So when I spawn the floating text as well as the explosion effect.

10:50.800 --> 10:55.000
So let's go to top of our class and we're going to make it over here.

10:55.000 --> 10:56.760
So let's make it public.

10:57.000 --> 11:00.800
And we're going to create a game object container.

11:00.800 --> 11:03.880
And we need a reference to that floating text prefab.

11:03.880 --> 11:05.800
So we're going to type floating text.

11:05.800 --> 11:07.120
Basically we have to name it.

11:07.120 --> 11:10.040
So I'm going to call it something like floating text prefab.

11:10.480 --> 11:14.720
And also we need the explosion effect reference.

11:14.720 --> 11:18.120
So we're going to create a another public game object.

11:18.120 --> 11:24.120
And this one is just going to be explosion explosion effect effect.

11:24.360 --> 11:29.800
And we also need to create the point basically where I want to show the explosion effect.

11:29.800 --> 11:32.560
So I'm going to show the explosion effect from the bottom.

11:32.560 --> 11:36.600
So I'm going to create or we need a reference of a bottom position.

11:36.600 --> 11:42.400
So we're going to create a point a position from in this anime anime two game object, and from that

11:42.400 --> 11:44.600
we're going to show up the explosion effect.

11:44.600 --> 11:51.520
So that's why we also need a reference of a position where we want to show the show up, the explosion

11:51.520 --> 11:51.960
effect.

11:51.960 --> 11:54.640
Or you can simply pass transform dot position.

11:54.640 --> 11:58.080
So you don't need to have a reference of any position.

11:58.080 --> 12:04.360
Transform dot position basically means centered position of our anime game object or the current position.

12:04.360 --> 12:10.280
But I'm going to create a a point from where I want to spawn my explosion effect.

12:10.280 --> 12:15.160
So that's why I'm going to create a public transform which is responsible for position.

12:15.160 --> 12:20.160
And we can simply call it something like spawn effect point or position.

12:20.160 --> 12:22.160
So I'm going to call it something like point.

12:22.160 --> 12:23.280
And let's close that up.

12:23.280 --> 12:23.800
Semicolon.

12:23.800 --> 12:26.880
Let's press down Ctrl S in order to save our script.

12:26.880 --> 12:29.840
And I'm going to remove this start function from here.

12:29.840 --> 12:33.520
And also this comment I don't need this for now.

12:34.480 --> 12:36.910
And let's press down Ctrl s to save scrape.

12:36.910 --> 12:38.990
And let's move to unity by now.

12:38.990 --> 12:41.830
So we need to assign those variables one by one.

12:41.830 --> 12:44.790
So the first thing just gonna appear our floating text.

12:44.790 --> 12:51.110
So we can see underneath our enemy to scrape a floating text prefab just appears slot appear and it

12:51.110 --> 12:51.790
says none.

12:51.830 --> 12:53.270
Game object means empty.

12:53.270 --> 12:58.670
So we need to drag the floating text prefab game object over to this slot.

12:58.670 --> 13:01.430
And then also we need to drag the explosion effect.

13:01.430 --> 13:05.110
So let's go to project tab, then assets and then prefabs folder.

13:05.110 --> 13:07.710
I have the explosion over here as you can see.

13:07.710 --> 13:11.870
So I'm going to select and I'm gonna drag it over to this explosion effect slot.

13:11.910 --> 13:14.990
And I'm going to select my floating text game object.

13:14.990 --> 13:19.190
And I'm going to drag it over to this floating text prefab game object.

13:19.190 --> 13:24.430
And also we need to need a point from where I want to show up the explosion effect.

13:24.430 --> 13:28.670
So I'm going to create an empty game object in this anime to game object.

13:28.670 --> 13:31.350
So let's right click on this anime two game object.

13:31.350 --> 13:33.590
And let's create an empty game object.

13:33.590 --> 13:39.540
And I'm going to name this claim object to something like spawn effect point or spawn effect position.

13:39.540 --> 13:43.540
So I'm going to call it spawn effect effect point.

13:43.900 --> 13:45.620
And I'm going to move this one.

13:45.660 --> 13:52.580
Sorry, I'm going to move this one in the bottom or fit of my this anime game object somewhere over

13:52.580 --> 13:58.780
here not in bottom because the center position of the explosion just going to be over here.

13:58.780 --> 14:04.460
So the bottom just gonna cover up and I'm going to choose energy gizmos for that as well.

14:04.500 --> 14:09.540
And now let's select our anime script and let's drag the spawn effect point right there.

14:09.540 --> 14:11.700
Now we can see we have the reference.

14:11.700 --> 14:14.580
So I'm going to move over to overrides and then apply all.

14:14.580 --> 14:16.940
So we have all of those things.

14:16.940 --> 14:19.580
So let's open up our anime two script by now.

14:20.060 --> 14:23.460
And we're taking the damage over here as you can see.

14:23.460 --> 14:31.020
So what we're going to do we also gonna spawn the basically we also want to spawn that floating text

14:31.020 --> 14:32.900
prefab once we take damage.

14:32.900 --> 14:35.540
So I'm going to use this instantiate function.

14:35.540 --> 14:37.060
And this function over here.

14:37.060 --> 14:40.700
It's going to take as a first argument the game object you want to spawn.

14:40.700 --> 14:44.380
So I'm going to pass my floating text prefab game object.

14:44.380 --> 14:46.340
And the second thing it's going to take the position.

14:46.340 --> 14:52.180
So I'm going to pass my transform dot position means the current or center position of our enemy to

14:52.220 --> 14:52.940
game object.

14:52.940 --> 14:55.060
And the third thing it's going to take the rotation.

14:55.060 --> 14:56.660
So we're going to pass quaternion.

14:56.660 --> 14:59.660
Dot identity basically means no rotation.

14:59.660 --> 15:01.580
And let's close that up with semicolon.

15:01.780 --> 15:04.300
And we also need to show up the explosion effect.

15:04.300 --> 15:06.500
So let's move over to die function.

15:06.500 --> 15:09.740
So before we dive we're going to spawn the explosion effect.

15:09.740 --> 15:14.140
So before we dive we're going to use this instantiate function as a first argument.

15:14.140 --> 15:18.060
It's going to take the explosion effect or the game object you want to spawn.

15:18.060 --> 15:20.220
So in our case explosion effect.

15:20.220 --> 15:22.460
And the second thing it's going to take the position.

15:22.460 --> 15:26.900
So we have the position which is our spawn effect position.

15:26.900 --> 15:33.970
So we need as a second argument we're going to pass that which is spawn effect is spawn effect point.

15:33.970 --> 15:38.690
And then we're going to access the position basically where from where we want to spawn.

15:38.690 --> 15:45.050
So I just move it over to spawn effect position basically this one and then access this position.

15:45.530 --> 15:49.210
And now the second uh third thing, it's going to take the rotation.

15:49.210 --> 15:53.250
So I'm going to pass quaternion dot identity basically means no rotation.

15:53.250 --> 15:55.410
And let's close that up with semicolon.

15:55.410 --> 15:58.010
And I'm going to press down Ctrl s to save my script.

15:58.010 --> 15:59.810
And let's move to unity by now.

15:59.810 --> 16:01.650
And let's have a look on that.

16:07.610 --> 16:09.010
So just wait for to compile.

16:09.010 --> 16:11.530
And once it's done we are ready to do that.

16:11.850 --> 16:19.210
So now let's have a look on this and make sure you just drag all of the reference one by one into that,

16:19.930 --> 16:21.770
into those corresponding slot.

16:21.930 --> 16:25.530
And let's click on this play button in the top to play our game.

16:25.530 --> 16:27.770
And we're going to take a look on that.

16:28.010 --> 16:30.840
So just wait for it to compile and have a look on this.

16:32.440 --> 16:39.800
So now if I just, uh, just, uh, basically shoot on this anime game object, we can see it's just

16:39.800 --> 16:43.760
getting spawning and, uh, explosion effect as well.

16:43.760 --> 16:49.480
But the problem is that if I pause my game and then move over to hierarchy, we can see the explosion

16:49.480 --> 16:56.400
effect is still there as well as, uh, we don't have the floating text, so we can just ignore that

16:56.400 --> 17:01.880
so we can still able to see our explosion effect, as you can see.

17:01.880 --> 17:07.640
So we need to destroy this explosion effect after some period of time, basically, after completing

17:07.640 --> 17:13.240
the explosion effect animation or after that amount of time, we're gonna destroy that.

17:13.240 --> 17:16.520
So we're gonna get out of play mode and let's move over to Inspector.

17:16.520 --> 17:17.880
We get an error.

17:17.880 --> 17:23.000
So if I just double click there so we can simply ignore this.

17:23.280 --> 17:24.720
So now what are we going to do?

17:24.720 --> 17:25.720
We're going to destroy that.

17:25.720 --> 17:28.520
So let's open up our animated script quickly.

17:29.000 --> 17:31.600
And over here, as you can see, we spawning.

17:31.600 --> 17:37.680
So after spawning that explosion effect prefab we're going to store that into another GameObject or

17:37.720 --> 17:39.080
another container.

17:39.080 --> 17:40.040
So we're going to store that.

17:40.040 --> 17:45.680
So let's make a game object because this is explosion effect itself a whole game object.

17:45.680 --> 17:49.680
So that's why we need to put it in a container called a game object.

17:49.680 --> 17:55.360
And we have to name the container or the variable where we want to store it or where we want to store.

17:55.360 --> 18:02.040
So I'm going to call it something like name explosion game explosion a effect.

18:02.520 --> 18:07.520
And let's set equal to this name basically means temporary name explosion effect.

18:07.520 --> 18:12.400
So basically we spawn it this explosion effect at this point with no rotation.

18:12.400 --> 18:18.760
And after that we just taking this explosion effect what we spawn it we storing that into this explosion

18:18.760 --> 18:20.440
effect as you can see.

18:20.440 --> 18:24.280
So we directly setting it basically means we just storing that.

18:24.280 --> 18:31.870
So we also need to delete the container or where we store spawn where we stored that explosion effect.

18:31.870 --> 18:35.390
So we need to destroy as well that whole game object.

18:35.390 --> 18:36.190
So let's do that.

18:36.190 --> 18:39.870
So after storing that we're going to use this destroy function.

18:39.870 --> 18:42.470
And this destroy function is the first argument.

18:42.470 --> 18:45.150
It's going to take the game object we want to destroy.

18:45.150 --> 18:47.350
So in our case we're going to destroy.

18:47.350 --> 18:54.950
This explosion effect basically means where we store the explosion effect prefab after spawning that

18:55.190 --> 18:59.870
and we're going to destroy basically we just destroying the whole container where we store it.

18:59.870 --> 19:05.150
And as a second argument, we need to specify the time after which amount of time.

19:05.350 --> 19:07.390
You just want to destroy that.

19:07.390 --> 19:13.110
And if you just don't assign it with anything and then close that up with semicolon, it's gonna destroy

19:13.150 --> 19:13.870
right away.

19:13.870 --> 19:19.470
But we do know we need to play the 100% animation clip of the explosion effect.

19:19.470 --> 19:21.870
And after that amount of time, we're gonna destroy.

19:21.870 --> 19:23.460
So that's why, as a comma.

19:23.460 --> 19:27.020
We're going to specify this at the time as a second argument.

19:27.020 --> 19:31.900
So before we do make sure you just go to unity and then project tab prefabs folder.

19:31.900 --> 19:38.260
Basically open up that explosion effect and move over to this animation and see after which amount of

19:38.260 --> 19:43.820
time, after how amount or how much amount of time you just completing the animation clip.

19:43.820 --> 19:48.900
And you can see 0.9 just a lesser than little bit one second.

19:48.900 --> 19:53.660
So we're going to put 0.9, which is going to be perfect time, because after this amount of time,

19:53.660 --> 20:00.180
we can see the animation is just completing whole basically one over here just referencing one second,

20:00.340 --> 20:04.380
you can simply say, so this is going to be over here 0.9 second.

20:04.380 --> 20:06.860
So as a second argument we're going to specify the time.

20:06.860 --> 20:08.060
So let's go back.

20:08.220 --> 20:09.460
Let's go to script.

20:09.460 --> 20:12.540
And as a second argument I'm going to pass 0.9 F.

20:12.580 --> 20:14.860
And let's Ctrl s to save our script.

20:14.860 --> 20:17.300
And let's move to unity.

20:17.340 --> 20:22.170
Basically press down Ctrl S in order to save your script and then move to unity.

20:22.850 --> 20:30.770
So after 0.98 second, you will see that will be also destroy the container where we store it.

20:30.770 --> 20:33.330
So let's see let's see that.

20:33.330 --> 20:37.130
So I'm going to click on this play button in the top and have a look on this.

20:39.930 --> 20:41.570
So just wait for to compile.

20:41.570 --> 20:44.250
And once it's done we are ready to do that.

20:44.250 --> 20:52.250
So if I just attack on this uh, anime two game object and we can see it's getting destroyed and we

20:52.250 --> 20:54.530
still able to see this line renderer.

20:54.530 --> 20:56.930
So we also need to, uh, destroy that.

20:56.930 --> 21:00.250
So if I move over to console, then open up the anime script.

21:00.810 --> 21:02.650
Uh, so we're doing it over here.

21:02.650 --> 21:08.690
So we just, uh, basically what we're doing, we're just checking if, uh, startcoroutine over here,

21:08.690 --> 21:09.970
as you can see.

21:09.970 --> 21:11.530
So what we will do for.

21:11.570 --> 21:14.930
So we're gonna remove this messages, uh, messages.

21:14.930 --> 21:20.810
So basically what we are doing over here, uh, we basically destroying this enemy game object, but

21:20.810 --> 21:22.610
we still able to damage it.

21:22.610 --> 21:24.690
Or just shooting that line runner.

21:24.730 --> 21:25.850
As you can see.

21:25.850 --> 21:31.650
So before we shoot or do all of these things or damage this enemy to game object, we need to check

21:31.650 --> 21:35.930
if this enemy to game object is still in the scene view means in the game or not.

21:35.970 --> 21:41.650
If it's totally destroyed, means we need to stop doing what we're doing, like taking damage.

21:42.010 --> 21:43.290
So we need to do that.

21:43.290 --> 21:44.650
So let's go to step.

21:44.650 --> 21:51.010
And before we do all of these things, or we can simply go over to this where we just clicking the left

21:51.010 --> 21:54.010
mouse button and we just simply doing these things.

21:54.010 --> 21:58.770
So or we can simply move over to this shoot function in enumerator.

21:58.770 --> 22:03.690
And we can check over here what we will check we will check over here.

22:03.690 --> 22:11.170
We're going to check if uh if we're going to use this find any object uh object by type.

22:11.570 --> 22:15.130
So make sure you use this and into arrows.

22:15.130 --> 22:19.040
You need to pass the script name which is script you want to check for.

22:19.080 --> 22:22.120
So let's suppose this anime two game object just died.

22:22.160 --> 22:25.640
So with this, this anime two script is also gonna be destroyed.

22:25.680 --> 22:30.440
As you can see, the anime two script is attached to this anime two game object.

22:30.440 --> 22:35.960
Which means if we destroy this anime two game object, the script will be also be destroyed.

22:35.960 --> 22:37.360
So we're going to check right there.

22:37.360 --> 22:42.520
So we will pass the anime two script and we will check if this anime two script.

22:42.960 --> 22:49.560
So make first bracket and some the basically make sure you just doing as I did over here.

22:49.560 --> 22:55.760
So we simply going over to this anime two script and we're going to check if this anime two script is

22:55.760 --> 23:02.600
equals equals to null equals equals to null basically means empty means we don't have the enemy to script

23:02.600 --> 23:07.920
in this in view or in the game means the anime two game object gets destroyed.

23:07.920 --> 23:13.600
So in that situation, we need to stop doing all of these things like setting up the line renderer,

23:13.640 --> 23:16.190
shooting out on enemy game object.

23:16.190 --> 23:16.870
So that's why.

23:16.910 --> 23:19.070
So we're going to make some curly brackets.

23:19.070 --> 23:20.550
So we're checking over here.

23:20.550 --> 23:25.510
If the enemy to skip is equals equals to null basically means enemy to skip.

23:25.550 --> 23:26.510
Just get destroyed.

23:26.510 --> 23:30.590
And we don't have enemy to skip in this in view or in the game.

23:30.590 --> 23:34.270
So we need to stop shooting on our enemy to game object.

23:34.270 --> 23:36.230
So that's why we're going to type this return.

23:36.230 --> 23:40.870
And we do know after return whatever we're gonna do it's not gonna work.

23:40.990 --> 23:43.390
Uh, not work, it's not gonna work.

23:43.430 --> 23:46.230
And we get some error, as you can see.

23:46.390 --> 23:52.150
So what we're going to do, we're going to put this line of code, uh, over here where we're just clicking

23:52.150 --> 23:55.950
the left mouse button and then shooting on this enemy two game object.

23:55.950 --> 23:57.470
So we're going to put this line of code.

23:57.470 --> 24:00.510
So I'm going to press down Ctrl X in order to cut.

24:00.550 --> 24:05.350
And I'm going to paste it over here where we just clicking by Ctrl V.

24:05.510 --> 24:08.190
As you can see by now it should be fine.

24:08.190 --> 24:10.950
So let's press down Ctrl S to save our skip.

24:10.950 --> 24:12.910
And now let's move over to unity.

24:12.910 --> 24:16.590
So we will see that error just be gone by now.

24:16.590 --> 24:21.670
But let's have a look on that before we just, uh, do those things.

24:22.070 --> 24:25.110
So we need to check if it's perfectly working or not.

24:25.110 --> 24:27.870
So we should not see any messages.

24:27.870 --> 24:30.030
So let's click on this play button in the top.

24:30.030 --> 24:31.990
And let's take a look on this.

24:38.110 --> 24:42.430
So if I just, uh, shoot on this anime two game object, you will see that.

24:45.190 --> 24:49.950
Still we able to see and we can see object reference is not set.

24:49.990 --> 24:51.230
So we need to fix that.

24:51.270 --> 24:54.830
We need to, uh, do something that we really want to do.

24:54.830 --> 24:59.430
So over here we're going to do that, but we're going to take a look or we're going to fix this bug

24:59.430 --> 25:01.030
into next lecture.

25:01.190 --> 25:04.550
And you can just leave it, uh, this one, it's totally fine.

25:04.550 --> 25:05.710
You just have to check.

25:05.710 --> 25:08.390
So make sure it's basically totally fine.

25:08.390 --> 25:11.630
So I'm going to press down Ctrl S in order to save my script.

25:11.670 --> 25:12.870
And let's move to unity.
