WEBVTT

00:00.040 --> 00:03.120
Would be nice if we able to see our array.

00:03.520 --> 00:04.800
So what we will do?

00:04.840 --> 00:11.320
We're going to add a line render component in order to able able to see our array.

00:11.360 --> 00:12.360
So let's do that.

00:12.360 --> 00:15.120
We're going to select our player GameObject in the hierarchy.

00:15.120 --> 00:16.360
And let's click add.

00:16.480 --> 00:18.360
Let's click on this add component.

00:18.360 --> 00:21.560
And we're going to add a component called Line Renderer.

00:21.560 --> 00:24.560
So we're going to type the component name which is line renderer.

00:24.600 --> 00:27.680
As you can see, as soon as we type it gets pop up.

00:27.680 --> 00:30.080
And we're going to click there in order to attach.

00:30.240 --> 00:33.480
So make sure you just go to this line render component.

00:33.680 --> 00:36.000
Then materials you're going to find in the bottom.

00:36.000 --> 00:40.760
So scroll down a bit and materials and we can see it says none materials.

00:40.760 --> 00:43.880
So just click there and then select this default.

00:43.880 --> 00:48.160
Or you can simply type over here as well which is the default.

00:48.280 --> 00:49.440
And we're going to attach.

00:49.440 --> 00:54.200
And after doing that just move over to this position and then size.

00:54.200 --> 00:58.640
And we're going to make in the X something like five in order to be able to see.

00:58.640 --> 01:05.670
So as you can see we can see our array and uh, we can see or we can set the position as well.

01:05.670 --> 01:09.270
So I'm going to move over to this index and we can set the position.

01:09.270 --> 01:14.870
So I'm going to move over to in the Y a little bit up something like this.

01:15.830 --> 01:19.350
Sorry one and one we're going to do.

01:19.390 --> 01:25.590
As you can see now we are able to see our line renderer and we're going to adjust it.

01:25.590 --> 01:30.230
So uh so move over to this width and we're going to make it a little bit thickness.

01:30.230 --> 01:32.990
So we can simply select this red line.

01:32.990 --> 01:36.870
And we're gonna drag it down to make it a little bit thicker.

01:36.910 --> 01:38.470
Something much this.

01:38.470 --> 01:45.510
And I'm going to make it a little bit with a little bit up something around over here.

01:45.710 --> 01:49.990
And if you want to choose any color you can just move over to this color.

01:50.270 --> 01:51.750
Then you can choose the color.

01:51.750 --> 01:57.030
So in the right side click over here this and then click on this color.

01:57.030 --> 02:00.140
And you can choose the color that you want to choose.

02:00.140 --> 02:03.060
And I'm going to select this one and I'm going to delete it.

02:03.060 --> 02:06.300
So as soon as we delete we can see it's red.

02:06.300 --> 02:10.580
And you can choose the color which color you want to set with.

02:10.900 --> 02:15.980
But I'm gonna move I'm gonna basically what I'm gonna do, I'm gonna go with this red color.

02:16.220 --> 02:23.420
And now what we will do, we're gonna open up our player script in order to set this line render position

02:23.420 --> 02:26.900
as well as, uh, the where we just want to do that.

02:26.900 --> 02:30.700
So we also need to set this to be enable or disable.

02:30.740 --> 02:35.500
As you can see we can enable that as well as we can disable that.

02:35.500 --> 02:37.500
So let's open up our player script.

02:37.540 --> 02:42.660
And we need a reference of this line renderer component in order to set that.

02:42.660 --> 02:46.060
So let's open up our player script by double clicking on it.

02:46.060 --> 02:48.500
And we will move to the top of our class.

02:48.500 --> 02:51.300
And let's create another public variable.

02:51.460 --> 02:53.180
So let's click a public.

02:53.220 --> 02:56.260
And the component we're looking for is a line renderer.

02:56.260 --> 02:58.180
So we're going to type line renderer.

02:58.180 --> 03:04.210
And we can call it something like LR, short for line renderer, and then close that off with semicolon

03:04.210 --> 03:09.050
control for control S for saving your script and move over to unity.

03:10.810 --> 03:14.770
So underneath our player Skip we're going to see another fill.

03:14.770 --> 03:16.930
And that will be line renderer.

03:16.930 --> 03:23.410
So what we need to do there we need to basically drag the line renderer component in there.

03:23.410 --> 03:24.850
So we're going to have the reference.

03:24.850 --> 03:26.690
And then we can set the position.

03:27.170 --> 03:28.010
So just wait.

03:28.010 --> 03:31.210
As you can see LR and it says line renderer.

03:31.210 --> 03:33.330
So we're going to take our line render component.

03:33.330 --> 03:34.850
And we're going to drag it there.

03:34.850 --> 03:39.130
And we can see now we have a reference called player line Renderer.

03:39.130 --> 03:42.810
And now we are ready to set the position as well as the index.

03:42.810 --> 03:46.410
So let's open up our player script and what we will do.

03:46.450 --> 03:48.810
We're going to move over to this start function.

03:48.810 --> 03:52.170
And we do no start function get call in the start of the game.

03:52.170 --> 03:56.970
So in this start of the game what we want we just want to disable this renderer.

03:56.970 --> 04:03.720
So if we move to unity and then this line runner line renderer component and we can check it or uncheck

04:03.760 --> 04:08.600
it, check it, uncheck it basically means we just enabling or disabling it.

04:08.600 --> 04:13.000
So I'm gonna uh, what I'm gonna do, we're gonna do it with our script.

04:13.000 --> 04:15.520
So let's, let's move over to script.

04:15.520 --> 04:20.360
And then in the start of the game I just want to disable this blind renderer component.

04:20.360 --> 04:20.840
Why?

04:21.040 --> 04:23.480
Because we don't want this to be active.

04:23.520 --> 04:29.240
But once our player GameObject shoot out a ray something, once we click left mouse button, then we're

04:29.240 --> 04:31.560
gonna enable this line renderer.

04:31.560 --> 04:33.240
So basically that is the thing.

04:33.240 --> 04:37.640
So let's go to script and we're going to say line renderer and dot.

04:37.680 --> 04:41.160
We're going to use this enable parameter in order to set that.

04:41.160 --> 04:43.400
And we're going to set equal to false.

04:43.400 --> 04:48.520
False basically means we just disabling or if you pass through means enabling.

04:48.520 --> 04:51.840
So we just moving over to this line renderer component.

04:51.840 --> 04:55.400
And then we just disabling it in the start of the game.

04:55.400 --> 04:59.200
But once we click left mouse button then we need to enable this.

04:59.200 --> 05:00.800
So let's go to script now.

05:00.800 --> 05:02.120
And why are we doing.

05:02.200 --> 05:06.520
We just uh doing over here in shoot function as you can see.

05:06.520 --> 05:08.320
So we're going to do it over here.

05:09.480 --> 05:14.880
Uh, so uh, instead of using this shoot function we're going to use AI enumerator.

05:14.880 --> 05:15.320
Why?

05:15.600 --> 05:22.440
Uh, basically we want to enable this blind runner component a few second or a pretty short time, and

05:22.440 --> 05:24.800
then we're gonna disable that right away.

05:24.840 --> 05:27.000
We're going to enable for pretty short time.

05:27.000 --> 05:30.040
And after that we're gonna disable right away.

05:30.320 --> 05:37.400
Uh, after that or a short period of time, something like a millisecond or even we're gonna enable

05:37.400 --> 05:41.960
that blind runner point 5 or 0.2 second for a short moment.

05:41.960 --> 05:43.960
And after that we're gonna disable that.

05:43.960 --> 05:46.560
So that's why we're going to use this AI enumerator.

05:46.720 --> 05:49.440
So we need to get rid of this, uh, void.

05:49.600 --> 05:52.280
And we have to use this AI enumerator.

05:52.280 --> 05:58.630
So before you use that, make sure you just go to the top of your class and then include this name namespace.

05:58.670 --> 06:05.550
It's called using sorry as using a system dot collection.

06:05.830 --> 06:11.470
So you need to use this system dot collection in top of your, uh, unity class.

06:11.470 --> 06:17.830
So make sure you just go to top of your class and then use this namespace call using system dot collection.

06:17.830 --> 06:21.790
And it's gonna allow us to use I enumerator function.

06:21.790 --> 06:23.230
So we're going to do it over here.

06:23.230 --> 06:25.510
So we're going to get of uh our void.

06:25.510 --> 06:27.870
And we're going to type this I enumerator.

06:27.910 --> 06:29.510
Now we able to see.

06:29.510 --> 06:32.510
So why we using this I enumerator function.

06:32.510 --> 06:38.030
Because we're gonna wait for some moment and after that we're gonna disable that array right away.

06:38.030 --> 06:45.150
Or that line renderer for enabling for, uh, for enabling a few moments or few seconds.

06:45.150 --> 06:46.990
And after that, we're gonna disable.

06:46.990 --> 06:51.830
So this enumerator function is allow us to delay some line of code.

06:51.830 --> 06:59.020
Or if you want to do a, uh, if you want to do some specific things after some certain period of time,

06:59.300 --> 07:05.180
then you can use this AI enumerator function in order to do that and make sure why're you calling your

07:05.180 --> 07:05.860
function?

07:05.860 --> 07:08.100
You need to call it in a different way.

07:08.100 --> 07:11.980
So we just simply take the shift function or the name of the function.

07:11.980 --> 07:17.780
As you can see, instead of using that what we have to do, we need to use this startcoroutine.

07:17.820 --> 07:22.140
It's kind of a bit weird, but you have to use that and then make first bracket.

07:22.140 --> 07:26.660
And in this bracket you need to, uh, put the function that you want to call.

07:26.660 --> 07:28.420
So we're going to call this function.

07:28.420 --> 07:31.900
So that's why in this brackets we need to type the function name.

07:31.900 --> 07:37.580
So in our case shoot and make sure you make this first bracket because that itself a function.

07:37.580 --> 07:39.580
And then close that up with semicolon.

07:39.580 --> 07:42.500
So you need to call the function in this startcoroutine.

07:42.500 --> 07:45.100
It's kind of a bit weird but we have to do it.

07:45.100 --> 07:51.140
So we're using this I inner I enumerator function in order to delay some line of code.

07:51.380 --> 07:54.970
So what we're going to do now we're going to use this alert.

07:55.090 --> 08:01.370
So once we're calling the shoot function that what we want to what we have to do, we need to enable

08:01.370 --> 08:02.690
that this way.

08:02.690 --> 08:07.330
So that's why we will go to LR basically line runner line renderer.

08:07.330 --> 08:11.690
And then we're going to use this enable function in order to enable that.

08:11.690 --> 08:13.930
And we're going to set equal to true.

08:13.930 --> 08:18.890
Basically we just enable and after short period of time we're going to disable that.

08:18.890 --> 08:25.050
So that's why uh we're going to use this l return new wait for second.

08:25.050 --> 08:30.970
So you can use this new wait four seconds wait four seconds and then make first bracket.

08:31.010 --> 08:32.890
Then close that output semicolon.

08:33.050 --> 08:35.050
So we have to use this.

08:35.090 --> 08:40.010
It's called l return new wait for second so you can put the time over here.

08:40.010 --> 08:41.730
And after that what you gonna do.

08:41.730 --> 08:43.290
It's going to print out.

08:43.290 --> 08:50.530
So let's suppose uh we're going to say something like after 0.12 second or a pretty short period, uh,

08:50.530 --> 08:56.760
time, you can simply say, and after this amount of time that what we have to do, we need to disable

08:56.800 --> 08:59.440
our line renderer right away.

08:59.440 --> 09:04.600
So that's why we will go to LR, then enable and we're going to set equal to false.

09:04.600 --> 09:06.440
Basically we just disabling this.

09:06.440 --> 09:08.200
Firstly we age enabling.

09:08.240 --> 09:12.160
As you can see we just going over to this line renderer component.

09:12.160 --> 09:13.720
And then we just enabling.

09:13.760 --> 09:19.640
And after this period of time here return you wait for second this period of time what we're doing we're

09:19.640 --> 09:23.600
just going over to LR basically this line renderer component.

09:23.600 --> 09:28.640
And then we just disabling it after just enabling this period of time.

09:28.640 --> 09:32.360
And we're going to press down Ctrl S in order to save our script.

09:32.360 --> 09:34.200
And now let's move over to unity.

09:34.240 --> 09:38.280
Basically we want to see if it's perfectly working or not.

09:38.280 --> 09:40.760
So in this start of the game we just disabling.

09:40.800 --> 09:46.680
And once we click the left mouse button then we just enable link for short period of time.

09:46.680 --> 09:47.760
So let's have a look.

09:47.760 --> 09:51.320
So I'm going to click on this play button in the top in order to check it.

09:51.320 --> 09:57.270
So I'm going to click the left mouse button in order to enabling that line renderer.

09:58.510 --> 10:00.630
So I'm going to click the left mouse button.

10:01.390 --> 10:07.790
As you can see, as soon as we click, it just gets active and some period of time it just gets disabled.

10:07.830 --> 10:11.030
As you can see in the, in uh, in the scene view.

10:11.030 --> 10:12.470
So we just enabling that.

10:12.470 --> 10:18.870
And after some period of time we can see it's just getting disabled automatically because after that

10:19.110 --> 10:21.030
0.12 seconds which is disabling.

10:21.030 --> 10:22.630
So I'm going to get out of play mode.

10:22.630 --> 10:25.030
And now let's move over to script.

10:25.030 --> 10:26.310
And what we have to do.

10:26.350 --> 10:33.190
We need to set the position so we can only see this line just getting over here active and just it's

10:33.190 --> 10:39.710
getting the active, uh, after that amount of time and it just happening over here, instead of doing

10:39.750 --> 10:42.870
that, what we're going to do, we're going to set the line renderer.

10:42.870 --> 10:45.470
So we're going to store the first position over here.

10:45.590 --> 10:50.110
And we're going to store the second position the ray hit width.

10:50.110 --> 10:53.820
So let's suppose the ray hit with awe with this anime game object.

10:53.820 --> 11:00.380
Then we're going to set the second position of the line renderer component where the ray hit width.

11:00.380 --> 11:02.780
So let's go to script in order to do that.

11:02.780 --> 11:04.020
So let's go to script.

11:04.220 --> 11:06.780
And over here we're doing as you can see.

11:06.820 --> 11:12.140
But before we do after enabling our line renderer component, we're going to set the position.

11:12.140 --> 11:17.460
So we have to use this alert dot set position function and set position.

11:17.460 --> 11:19.580
And first make this first bracket.

11:19.620 --> 11:21.540
Then close it up with semicolon.

11:22.580 --> 11:25.980
So this alert dot set position as a first argument.

11:25.980 --> 11:28.020
Or it's going to take the index.

11:28.060 --> 11:33.580
So we're going to pass zero zero basically means we just gonna refer the first position.

11:33.820 --> 11:39.500
So we're going to store this position where the where we start our ray.

11:39.500 --> 11:44.180
So we're gonna we shooting out our ray from this shoot point position.

11:44.180 --> 11:49.460
So that's why we're going to store the first position in this index which is zero as you can see.

11:49.620 --> 11:55.250
So the position we're going to pass through points position or where from which just shoot shooting

11:55.250 --> 11:55.930
out the ray.

11:56.170 --> 12:01.130
We definitely gonna shoot out the ray from this position which is our should point out position.

12:01.130 --> 12:06.570
So we're going to pass our shoot point position or the first position into this zero index.

12:06.570 --> 12:15.090
So the position is just going to be shoot point shoot point dot position and shoot point dot position

12:15.090 --> 12:17.210
basically means where we shooting out the ray.

12:17.330 --> 12:20.850
So we're just shooting out the ray from this shoot point dot position.

12:20.850 --> 12:24.970
So that's why we just are taking our shoot point out position.

12:25.370 --> 12:28.130
And we're storing in this zero index.

12:28.130 --> 12:32.170
And we also need to set the second position as well.

12:32.570 --> 12:34.170
So we're going to do it over here.

12:34.170 --> 12:35.730
As you can see what we're doing.

12:35.730 --> 12:40.090
We're just printing out a message in the console says takes damage.

12:40.090 --> 12:47.610
So we also want to set the second position of that render line renderer component with our second index.

12:47.610 --> 12:49.970
So we're going to do it over here.

12:49.970 --> 12:57.410
So LR we're going to use this LR set position function in order to set the position and then make first

12:57.410 --> 12:58.090
bracket.

12:58.090 --> 12:59.850
So we're going to pass our index.

13:00.170 --> 13:03.650
Now we're going to store our second position the ray hit width.

13:03.650 --> 13:06.530
So the ray is just going to hit with this enemy game object.

13:06.530 --> 13:12.690
So where hit width we can store that position in our one index.

13:12.690 --> 13:16.010
So we just store it the first position in this zero index.

13:16.010 --> 13:19.410
Now we're going to store our second position in the one index.

13:19.410 --> 13:23.050
So firstly we're going to we have to type the index and then comma.

13:23.050 --> 13:29.970
And we have to pass the position which position we want to store into this index.

13:29.970 --> 13:36.290
So we're going to pass our hit info hit info dot point and then close that off with semicolon.

13:36.290 --> 13:41.130
So hit info dot point basically means the ray hit with the position.

13:41.130 --> 13:43.930
So the ray gonna hit with this enemy game object.

13:43.930 --> 13:51.360
So so the hit point dot hit info dot point basically means the position the ray collided with.

13:51.360 --> 13:54.640
So the ray is gonna collide with this, uh, enemy game object.

13:54.640 --> 14:02.040
So we're storing that point or or where the ray hit with we just storing that position into this one

14:02.040 --> 14:03.760
index, as you can see.

14:03.920 --> 14:07.240
So we're going to press on control S in order to save our script.

14:07.240 --> 14:08.720
And let's move to unity.

14:09.760 --> 14:14.400
So we firstly we're storing our first position into this zero index.

14:14.400 --> 14:21.520
And once the ray hit with then we're storing that uh, that uh or the second position which is storing

14:21.520 --> 14:24.080
in this one index as you can see.

14:24.200 --> 14:32.680
So let's move to unity now and let's click on this play button in the top in order to is able to see

14:32.680 --> 14:33.120
that.

14:33.360 --> 14:38.520
So once we click the left mouse button you will able to see the ray because we're storing the first

14:38.520 --> 14:40.800
position into zero index.

14:40.800 --> 14:43.600
So I'm going to click left mouse left mouse button.

14:43.600 --> 14:47.120
As you can see as soon as we click we can see the ray.

14:47.160 --> 14:51.670
Just uh, getting active with this or where the Ray hit with.

14:51.710 --> 14:53.790
We're just getting to that point as well.

14:53.790 --> 14:59.670
And I'm going to make the player speed a little bit slow, something like I'm gonna make, uh, in order

14:59.670 --> 15:01.470
to check something like 0.5.

15:01.630 --> 15:05.110
And let's click on this play button in the top in order to check it.

15:05.110 --> 15:07.270
And I'm going to check one more time.

15:07.270 --> 15:08.870
So I'm going to click left mouse button.

15:08.870 --> 15:15.390
And we will see that, uh, the ray just gonna active or enabled for a few minutes.

15:15.390 --> 15:17.990
And then it's gonna disable as you can see.

15:18.030 --> 15:23.390
And we can see the ray just getting shoot it, shoot it out from that shoot point dot position.

15:23.390 --> 15:26.110
And the ray just collided with this enemy game object.

15:26.110 --> 15:30.630
So that's why the second position, uh, we just store it in the one index.

15:30.630 --> 15:32.110
So I'm going to get out of play mode.

15:32.110 --> 15:35.550
And let's suppose this enemy game object is not there.

15:35.550 --> 15:41.550
So if I select my enemy GameObject in the hierarchy and I just disable it right away, go over to Inspector

15:41.550 --> 15:44.470
and you can just uncheck that in order to disable.

15:44.590 --> 15:51.420
And now if we click on this play button you will will not able to see the ray because the ray not are

15:51.420 --> 15:54.300
not getting collided with that enemy game object.

15:54.300 --> 15:56.380
So that's why we're not gonna able to see.

15:56.660 --> 16:01.980
So if I just click the left mouse button, as you can see, it's just moving over to negative direction

16:02.140 --> 16:04.620
or it's just shooting out from this position.

16:04.620 --> 16:06.140
But we don't want to do that.

16:06.140 --> 16:08.540
So I'm going to click on I'm gonna pause my game.

16:08.540 --> 16:12.540
So what we want to do let's suppose if there is no enemy.

16:12.540 --> 16:19.620
So we still want to see that line renderer or that ray and it's gonna shoot out with nothing and nothing.

16:19.620 --> 16:24.300
So we just want to, uh, want to see or want to set a event.

16:24.340 --> 16:26.220
It's just shooting nothing.

16:26.220 --> 16:28.820
So we want to see in the right direction.

16:28.820 --> 16:30.460
So let's get out of play mode.

16:30.460 --> 16:36.740
So the if the ray is not colliding with that enemy game object, then we still want to see our ray.

16:36.740 --> 16:38.180
So let's go to script.

16:38.180 --> 16:39.820
And we're doing it over here.

16:39.820 --> 16:46.420
As you can see if hit info basically means true means the ray is really colliding with that enemy game

16:46.490 --> 16:47.010
object.

16:47.010 --> 16:53.770
And let's suppose the array is not colliding with any game object, but we still want to see that line

16:53.770 --> 16:59.930
renderer, and we're going to set the line renderer as the this as the length of the array.

16:59.930 --> 17:02.330
So that's why we're going to use this else condition.

17:02.370 --> 17:06.050
Else the array is not colliding with our enemy game object.

17:06.050 --> 17:12.210
But we still want to set the position of that renderer component with the distance or the length of

17:12.250 --> 17:12.810
the array.

17:13.410 --> 17:15.730
So that's why we're going to use this else condition.

17:15.730 --> 17:19.250
And we're going to check we're going to set the position which is LR dot position.

17:19.250 --> 17:24.810
We need to use this function in order to set the position and close that off with semicolon.

17:24.810 --> 17:27.570
So the array will not collide with anything.

17:27.570 --> 17:31.370
So we're going to store the position in this one index comma.

17:31.530 --> 17:35.290
And it's going to take the position where we want to set a set.

17:35.330 --> 17:39.210
We do know that we're not going to collide with any enemy game object.

17:39.210 --> 17:41.610
So we are gonna shoot in nothing.

17:42.210 --> 17:44.290
But we still want to say see.

17:44.490 --> 17:48.160
So that's why we're going to use this transformer, right?

17:48.200 --> 17:49.120
Transform, right.

17:49.480 --> 17:49.760
Dot.

17:49.800 --> 17:50.080
Right.

17:50.080 --> 17:52.920
Basically means, uh, in which direction we're shooting.

17:53.680 --> 17:55.760
So we're just shooting in the right direction.

17:55.760 --> 17:57.520
So that's why transport dot right.

17:57.560 --> 17:59.280
Basically means the direction.

17:59.280 --> 18:03.480
And we're going to multiply that direction with our length of the ray.

18:03.600 --> 18:09.440
So we're going to multiply length or sorry we're going to use this distance basically distance.

18:09.440 --> 18:11.920
Uh by default we set in Inspector ten.

18:12.080 --> 18:14.600
And this is basically the length of the ray.

18:14.600 --> 18:19.400
So we basically multiplying our uh direction with our distance.

18:19.400 --> 18:25.080
So we're going to able to see the ray with the distance or the length of the ray which is ten by default.

18:25.080 --> 18:26.640
We set in inspector.

18:26.640 --> 18:30.560
And on top of that we're going to basically, uh, this will be direction.

18:30.560 --> 18:34.680
So we're going to we add this, uh transform dot.

18:34.720 --> 18:35.240
Right.

18:35.240 --> 18:39.240
So we're going to add shoot point shoot point dot position.

18:39.240 --> 18:41.280
And on top of that we're going to add this.

18:41.280 --> 18:45.470
So shoot point dot position basically means where we shoot it out the way.

18:45.470 --> 18:49.830
And on top of that, we're just adding our length of the ray, as you can see.

18:49.870 --> 18:55.990
And we also taking the direction and we multiplying with this distance basically means the ray length

18:56.030 --> 18:57.230
length of the ray.

18:57.230 --> 19:00.590
So we the so this just going to be like this.

19:00.630 --> 19:04.270
And we're just adding top of our shoot point top position.

19:04.270 --> 19:09.510
So point dot position means where we shoot it out the ray and top of that we just adding the length

19:09.510 --> 19:13.390
of the ray as you can see, because it's gonna shoot with nothing.

19:13.390 --> 19:17.870
But we still want to say see the ray as the length of our ray.

19:17.870 --> 19:18.910
So that's why we type.

19:18.950 --> 19:21.470
Firstly we take taking the direction.

19:21.470 --> 19:24.750
So we're going to shoot out in the right direction the ray.

19:25.070 --> 19:27.550
And we just multiplying with our distance.

19:27.550 --> 19:29.870
So we're gonna able to see our ray.

19:30.230 --> 19:36.790
So this is the second position where uh when we're shooting in nothing which is storing this position

19:36.990 --> 19:42.790
into this one index once the ray is not colliding with any enemy game object.

19:42.790 --> 19:46.220
So let's press down control S in order to save our skip.

19:46.220 --> 19:48.220
And now let's move over to unity.

19:48.220 --> 19:55.020
But if you still are a little bit confused, then of course I will give a another video in the resources

19:55.020 --> 20:01.060
about shooting out prey, and you can check that out if you just want to learn it more.

20:01.100 --> 20:06.420
Firstly, what we're doing, we just taking our position from where we shoot it out, the way we just

20:06.420 --> 20:11.940
shoot point dot position and on top of that we just taking the direction and we multiplying with the

20:11.940 --> 20:14.140
length of the ray, which is distance.

20:14.140 --> 20:20.380
So uh, so we're going to able to see our line renderer with the length of the ray which is ten.

20:20.380 --> 20:26.820
By default we set and we just storing the second position for when we shoot in nothing into this one

20:26.820 --> 20:28.340
index, as you can see.

20:28.380 --> 20:32.740
And the first position we just store it in this zero index.

20:33.060 --> 20:36.860
So we're going to press down Ctrl S to save our script and move to unity.

20:36.860 --> 20:39.100
And let's click on this play button by now.

20:39.220 --> 20:43.450
And you will able to see that as well.

20:44.170 --> 20:49.410
So just wait for to compile and if we should nothing.

20:49.410 --> 20:50.810
And then click left mouse button.

20:50.810 --> 20:54.090
And now we are able to see our array.

20:54.130 --> 20:55.250
As you can see.

20:55.290 --> 21:00.210
And after 0.12 second it's just getting disabled automatically.

21:01.050 --> 21:02.490
Let's get auto play mode.

21:02.490 --> 21:03.730
And let me explain.

21:03.730 --> 21:10.690
If we move to script, as you can see firstly we enabling our line renderer and then after we just disabling.

21:10.690 --> 21:14.170
So we use this else return new wait for second.

21:14.170 --> 21:20.410
And you have to put in this brackets the time in which uh after this amount of time it's going to be

21:20.410 --> 21:21.090
disabled.

21:21.130 --> 21:27.050
As you can see, after enabling and after this amount of time, we just disabling our line renderer

21:27.050 --> 21:33.370
component LR dot enable equal to false basically means we just disabling and make sure you just call.

21:33.610 --> 21:39.250
Basically we use this eye enumerator should function in order to delay some line of code.

21:39.250 --> 21:40.810
So we need to use that.

21:40.810 --> 21:48.010
So if you just want to delay any some certain things after some period of time, then you can use this

21:48.050 --> 21:49.610
AI enumerator function.

21:49.610 --> 21:55.850
In order to do that, instead of using void, we need to use this AI enumerator and you have to name

21:55.850 --> 21:57.930
the function what we want to name it.

21:57.930 --> 22:03.450
But before you include this function, make sure you just go to the top of your class and include this

22:03.450 --> 22:06.410
namespace called using system dot collection.

22:06.410 --> 22:11.530
And it's gonna allow us in order to use our enumerator function.

22:11.530 --> 22:14.050
And you need to call function in a weird way.

22:14.090 --> 22:18.490
Firstly you need to use this startcoroutine and you need to make this brackets.

22:18.490 --> 22:21.810
And in this bracket you need to call the function.

22:21.810 --> 22:24.010
In our case shoot as you can see.

22:24.010 --> 22:27.170
So we're using this Startcoroutine and then shoot function.

22:27.170 --> 22:31.650
And when we doing once we click our left mouse button as you can see.

22:31.650 --> 22:33.490
So basically this is the cool thing.

22:33.730 --> 22:39.170
And once once we shooting in nothing then we just taking our second position.

22:39.170 --> 22:45.960
And we storing in this one More in this index, which is one or which is storing our second position

22:45.960 --> 22:47.360
in this bond index.

22:47.360 --> 22:53.600
But once the ray collides with that anime game object and hitpoint dot hit info dot point basically

22:53.600 --> 22:56.240
means the ray hit with that enemy game object.

22:56.240 --> 23:02.440
So we're just taking that position where the where our Ray hit with anime game object, we're just taking

23:02.440 --> 23:05.840
that position and we're storing in this one index.

23:05.840 --> 23:14.680
But once our ray is shooting nothing, then we just are taking our position with where we just were

23:14.680 --> 23:20.480
shoot it out and we just taking the length of the ray and we're storing that whole thing or that position

23:20.480 --> 23:22.200
in this one index.

23:22.200 --> 23:23.520
As you can see.

23:23.520 --> 23:29.920
I hope you get the idea that how you can do it and make sure you just press down Ctrl s in order to

23:29.960 --> 23:30.360
save.

23:30.400 --> 23:33.760
And let's suppose we just want to enable our enemy game object.

23:33.760 --> 23:38.360
And I'm going to make our a our player jump a little bit high.

23:38.440 --> 23:41.110
So I'm going to select my player game object in the hierarchy.

23:41.350 --> 23:43.870
And I'm going to make the player script.

23:43.870 --> 23:49.150
Or let's move to player script and I'm going to make the jump height something like 20 in order to check

23:49.190 --> 23:50.190
or 25.

23:50.310 --> 23:53.350
And I'm going to enable my enemy GameObject for now.

23:53.350 --> 23:57.630
So let's select the enemy GameObject in the hierarchy and let's enable that.

23:58.310 --> 24:00.350
And we will able to see by now.

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

24:03.150 --> 24:08.710
So once we shooting nothing the ray will still we will able to see our ray.

24:08.870 --> 24:13.350
But once the ray collide with this enemy GameObject you will see the ray will be set.

24:13.390 --> 24:20.070
Position the second position with this enemy GameObject where the ray collided with this enemy GameObject

24:20.510 --> 24:21.590
and we can see.

24:21.630 --> 24:29.470
And once we jump and shoot shoots in nothing, we still are gonna able to see our Ray or we just setting

24:29.470 --> 24:30.710
the line renderer.

24:31.030 --> 24:35.350
Uh, in our in nothing as you can see.

24:35.670 --> 24:40.660
And our background seems a little bit weird, basically, uh, the parallax effect.

24:40.700 --> 24:41.500
Then you can.

24:41.700 --> 24:44.460
Then you have to adjust the perfect position.

24:45.140 --> 24:47.060
And I'm gonna get out of play mode.

24:47.260 --> 24:50.780
And we will select our player GameObject in the hierarchy.

24:50.780 --> 24:54.260
Let's go to overrides and then click on this Apply All.

24:54.420 --> 24:58.660
And I want to move this line render component in my player GameObject.

24:58.660 --> 25:03.340
In the Inspector, I just want to move it up so we cannot do it over here.

25:03.340 --> 25:06.180
Instead we need to open that in prefab mode.

25:06.180 --> 25:09.020
So I'm going to click on this open in the Inspector.

25:09.380 --> 25:13.900
And now what I'm going to do I'm going to right click on this line renderer component.

25:13.900 --> 25:16.060
And I'm going to click on this pop up.

25:16.100 --> 25:19.540
In order to move this component in top of this player, skip.

25:19.540 --> 25:24.900
And if you just want to move it a little bit up, then you can just right click and then click on this

25:24.940 --> 25:25.540
move up.

25:25.540 --> 25:29.700
So it's gonna move up that component in top of the inspector.

25:29.700 --> 25:31.660
And you're gonna able to see that.

25:31.660 --> 25:34.380
And if you just want to go back in normal mode.

25:34.380 --> 25:36.700
So in hierarchy you can see back arrow.

25:36.700 --> 25:39.220
So just click there in order to go back.
