WEBVTT

00:00.000 --> 00:01.560
What we will do by now.

00:01.560 --> 00:08.520
We're going to create a circle around this anime game object, and if this player game object get inside

00:08.520 --> 00:11.440
of it, then we will stop patrolling.

00:11.440 --> 00:14.800
Instead, we're gonna attack on this player game object.

00:14.800 --> 00:18.960
So we will do the same thing as we have done with anime one game object.

00:18.960 --> 00:20.200
So let's do that.

00:20.200 --> 00:26.960
But in this situation, we're gonna stop patrolling once our player game object gets in attack range.

00:26.960 --> 00:28.200
So let's do that.

00:28.200 --> 00:31.520
So we will select our enemy game object in the hierarchy.

00:31.680 --> 00:37.480
Let's go over to enemy two script in Inspector, and let's double click on it in order to open that

00:37.480 --> 00:37.880
up.

00:38.160 --> 00:43.920
And now what we're gonna do, uh, we do know that we're gonna use that function called physics 2D.

00:44.400 --> 00:52.240
So let's create a first a variable to just keep track of if this player is attacked inside this attack

00:52.240 --> 00:53.200
range or not.

00:53.200 --> 00:55.480
So we're going to create a variable for it.

00:55.480 --> 01:01.350
So to create a circle around that we do know that we need some value.

01:01.350 --> 01:03.390
So let's create another header.

01:03.430 --> 01:04.630
Let's give it a title.

01:04.990 --> 01:07.070
So we're going to type header.

01:07.430 --> 01:09.750
And we will say something like attack.

01:10.510 --> 01:11.150
Attack.

01:11.750 --> 01:14.950
Sorry this will be attack attack.

01:14.950 --> 01:18.110
And then let's create a variable for this.

01:18.230 --> 01:25.830
So first variable will be just to keep track of if our player game object inside that gate attack range

01:25.830 --> 01:26.470
or not.

01:26.590 --> 01:28.630
So that will be bool parameter.

01:28.710 --> 01:32.910
We're just going to keep track of if the player is attack range or not.

01:32.910 --> 01:34.550
So we're going to make it private.

01:34.550 --> 01:38.310
It doesn't need to be public and that will be bull.

01:38.310 --> 01:45.070
And we can call this that is player is player in attack range.

01:45.270 --> 01:48.510
Something like that is player in attack range.

01:48.510 --> 01:50.830
And let's close that up with semicolon.

01:51.070 --> 01:54.270
And we will go over to this start function.

01:54.270 --> 02:00.070
So in the start of the game what we will do we will set is player attack range equal to false.

02:00.070 --> 02:01.650
Because in the start of the game.

02:01.650 --> 02:04.170
We're not going to be closer to this enemy.

02:04.690 --> 02:05.810
Enemy two game object.

02:05.810 --> 02:06.890
So that's why.

02:07.650 --> 02:09.410
And now let's create the circle.

02:09.450 --> 02:14.370
To create the circle first thing we need a point from where we want to create the circle.

02:14.370 --> 02:20.490
So since we're going to create the circle from center position of our enemy enemy two game object.

02:20.490 --> 02:22.410
So we don't need to define that.

02:22.410 --> 02:28.570
So so we just gonna use transform dot position which is basically means current position of that enemy

02:28.570 --> 02:29.290
two game object.

02:29.290 --> 02:30.890
So we don't need the position.

02:30.890 --> 02:33.850
But however we need the radius of it.

02:33.850 --> 02:41.770
So let's create a serialized field and this will be private float this we will this will be float.

02:41.770 --> 02:45.130
And we can call this one attack range radius.

02:45.370 --> 02:48.450
So let's call it attack range radius.

02:48.450 --> 02:53.210
And then by default I'm going to set it to something like six F or six unit.

02:53.410 --> 02:59.970
And the third argument we need that uh we which game object we really want to damage.

02:59.970 --> 03:02.720
So in our case we're gonna damage our player.

03:02.720 --> 03:05.320
So let's create another field.

03:05.480 --> 03:08.520
Or basically we want to check with player game object.

03:08.520 --> 03:09.400
So that's why.

03:09.560 --> 03:12.880
So we're gonna this will be private layer masks.

03:12.880 --> 03:15.760
And make sure you just mark this as a serialized field.

03:16.040 --> 03:18.680
And we can call this one something like target.

03:18.720 --> 03:21.080
Uh, target layer or --.

03:21.360 --> 03:24.400
Or you can say attack layer.

03:24.680 --> 03:27.720
Uh, but I'm going to call it What is player.

03:28.040 --> 03:30.640
Let's close that up with semicolon.

03:30.640 --> 03:34.000
And now we're going to press down Ctrl S to save our script.

03:34.000 --> 03:42.160
And uh so, so we don't need to move over to let's firstly move over to unity editor and let's assign

03:42.160 --> 03:43.200
those variable.

03:43.240 --> 03:47.480
So so the first thing just going to pop up which will be our attack radius.

03:47.520 --> 03:50.440
And the second thing will be uh what is ground.

03:50.440 --> 03:52.080
Basically the layer marks.

03:52.080 --> 03:55.280
So basically what we want to check with player.

03:55.280 --> 03:58.160
So as a layer mask we will choose our player.

03:58.400 --> 04:04.300
And before you choose your player make sure you assign your player game object as a player layer, as

04:04.300 --> 04:05.620
we have done already.

04:05.940 --> 04:07.100
So what is player?

04:07.100 --> 04:08.740
As you can see it says nothing.

04:08.740 --> 04:10.700
So we're going to choose our player.

04:10.700 --> 04:15.420
So this player the circle just going to check with this player game object only.

04:15.420 --> 04:23.020
So now let's open up our animator script and what we will do uh to create the circle let's move over

04:23.020 --> 04:24.620
to this update function.

04:24.620 --> 04:27.700
So this update function runs every single frame.

04:27.700 --> 04:31.980
So every single frame, uh, we just want to create the circle.

04:31.980 --> 04:35.460
Or we just want to keep track of where player is.

04:35.780 --> 04:40.340
So to create the circle we need to use this physics 2D dot overlap circle.

04:40.340 --> 04:43.100
We do no overlap circle.

04:43.100 --> 04:44.780
And this as a first argument.

04:44.780 --> 04:47.780
It's gonna take the point from where we want to draw.

04:47.780 --> 04:50.580
So we're going to pass our transform dot position.

04:50.580 --> 04:55.620
And transform dot position basically means current position of that animator game object.

04:55.620 --> 05:00.340
Or you can simply say center position of that animator game object.

05:00.340 --> 05:02.610
And the second thing, it's gonna take the radius.

05:02.610 --> 05:05.330
So I'm going to pass my attack range radius.

05:05.650 --> 05:08.530
And the third argument it's going to take the layer mask.

05:08.530 --> 05:12.530
So as a layer mask we will pass what is layer.

05:12.530 --> 05:14.690
And then close that up with semicolon.

05:14.690 --> 05:20.530
So the circle is just going to create from this a center position of this anime two game object with

05:20.610 --> 05:23.330
attack with attack range radius.

05:23.330 --> 05:28.570
And it's just going to check with this player game object, a player game object.

05:28.570 --> 05:35.210
So this as function right over here, it can give us a true or false value depending upon if the circle

05:35.210 --> 05:38.290
is really colliding with this player game object or not.

05:38.330 --> 05:44.170
If it's then this function over here, it's going to give us a true value, else it will give us a false

05:44.170 --> 05:44.770
value.

05:44.770 --> 05:51.130
So what we will do, we're going to store the result or a result into a collider 2D since this is just

05:51.130 --> 05:52.490
going to work as a collision.

05:52.490 --> 05:58.970
So that's why we need to put it in a variable or in a container which will be the container type will

05:58.970 --> 06:00.490
be collided 2D.

06:00.530 --> 06:08.110
Or you can simply say the parameter container and we can call this one call info or short for collision

06:08.110 --> 06:09.390
information.

06:09.390 --> 06:11.230
And let's set equal to this.

06:11.470 --> 06:14.350
So we're storing the result into this call info.

06:14.350 --> 06:20.510
So this call info right over here it can be true or false depending upon what this function is really

06:20.510 --> 06:20.910
doing.

06:21.110 --> 06:25.590
Basically if the circle collides with this player game object then it's gonna be true.

06:25.590 --> 06:32.990
So this call info will be true are true because we're storing the result into this collider 2D call

06:32.990 --> 06:34.230
info parameter.

06:34.430 --> 06:37.270
So this can be this info right over here.

06:37.270 --> 06:41.350
It can be true or false depending upon a circle.

06:41.390 --> 06:45.670
The circle is really colliding with that player game object or not.

06:45.670 --> 06:49.150
So what we will do now if the call info is true.

06:49.150 --> 06:49.990
So we will check.

06:49.990 --> 06:54.830
So let's make first bracket and some curly brackets and what we want to check over here.

06:54.830 --> 06:59.350
We basically want to check if call info is equals equals to true.

06:59.350 --> 07:00.990
Or we can just leave like this.

07:01.030 --> 07:06.420
It also means to means that the circle colliding with this player came object.

07:06.420 --> 07:07.860
So now what we need to do?

07:08.060 --> 07:09.420
We need to move our.

07:09.460 --> 07:11.740
We need to stop patrolling first.

07:12.180 --> 07:13.740
We need to stop patrolling.

07:13.740 --> 07:18.220
And after that we just need to get closer to this player game object.

07:18.220 --> 07:24.460
And once we reach some certain distance, then this enemy two game object need to play the attack animation

07:24.460 --> 07:30.060
clip, uh, attack animation clip that we created, as you can see right over here.

07:30.300 --> 07:34.620
So we forgot to make transition between this animation clip.

07:34.620 --> 07:35.980
So we need to do that.

07:35.980 --> 07:38.300
But we're going to take a look on it later.

07:38.740 --> 07:41.020
So let's uh, go to our script.

07:41.020 --> 07:45.700
And if call info is true basically means player in attack range.

07:46.020 --> 07:49.500
So what I'm gonna do, we just created this parameter.

07:49.500 --> 07:54.460
As you can see right over here it says is player in attack range.

07:54.460 --> 07:59.980
So what we will do, we will set it to true because we uh the circle just colliding with that player

07:59.980 --> 08:00.740
game object.

08:00.740 --> 08:07.480
So that's why we're going to set is player attack range that, uh, the, the variable that we created

08:07.480 --> 08:11.240
to just keep track of if the player in attack range or not.

08:11.320 --> 08:17.800
So we're going to set is player in attack range equal to true if call info is true basically means player.

08:17.840 --> 08:20.080
Just get inside of that circle.

08:20.080 --> 08:24.360
So that's why we're setting this is player attack in attack range to true.

08:24.400 --> 08:30.720
Let's suppose if the circle is not colliding with that player means it's just outside of the circle.

08:30.760 --> 08:31.640
Our player.

08:31.640 --> 08:38.800
So else else condition what we're going to do else if our player game object outside of that circle.

08:38.800 --> 08:45.640
So in this moment we're gonna set is player in attack range to false because it's not inside of that

08:45.640 --> 08:46.280
circle.

08:46.280 --> 08:50.520
So that's why we're going to set is player in attack range equal to false.

08:51.040 --> 08:52.160
Equal to false.

08:52.440 --> 08:53.720
And that's it.

08:54.240 --> 09:00.080
And now uh and now what we're going to do, we're going to press down control s to save our script and

09:00.080 --> 09:01.560
then move over to unity.

09:02.240 --> 09:09.590
So we should able to see the circle, but we not gonna be able to see that, uh, because we what we

09:09.590 --> 09:12.710
basically have to do, uh, we need to draw the circle.

09:12.710 --> 09:19.510
And we do know that for that, for that, we need to use a function calls on draw gizmo selected.

09:19.510 --> 09:23.270
So we will move over to one more time in our script.

09:23.270 --> 09:29.110
And over here we're gonna do, uh, the function we created, which is Ondraw gizmo selected.

09:29.110 --> 09:32.190
So let's do it in the bottom somewhere over here.

09:32.390 --> 09:38.150
To draw the circle, we need to use this gizmo straw where I sphere function.

09:38.150 --> 09:44.510
And we don't need to check if we assign it, uh, the position from where we want to create the circle

09:44.510 --> 09:49.590
since we do one, uh, since we want to draw the circle from center position.

09:49.590 --> 09:52.750
So that's why we don't need to assign a point for it.

09:53.030 --> 10:00.750
So that's why we're going to use directly this, uh, this gizmo dot draw where sphere and this, uh,

10:00.990 --> 10:04.810
this function as a first argument, it's going to take the point.

10:04.930 --> 10:10.010
So since we want from center position so we can simply type transform dot position.

10:10.330 --> 10:16.450
And before we draw the circle we don't need to assign this transform dot position because it's enemy

10:16.490 --> 10:20.770
center position or current position of that enemy to game object.

10:20.930 --> 10:23.290
And the second thing it's going to take the radius.

10:23.290 --> 10:25.850
So I'm going to pass my attack range radius.

10:25.850 --> 10:28.130
And let's close that up with some y colon.

10:28.330 --> 10:31.490
And also I want to choose a different color for this.

10:31.490 --> 10:34.410
So before we draw I'm going to assign a color.

10:34.410 --> 10:37.770
To assign a color we're going to use this gizmo dot color.

10:37.930 --> 10:41.370
And we can set the color that we would like to draw with.

10:41.370 --> 10:49.530
So I'm going to draw with color dot color dot something like green uh green something like that.

10:49.530 --> 10:51.730
And let's close that up with semicolon.

10:51.730 --> 10:57.210
And now I'm going to press Ctrl s on my keyboard in order to save my script.

10:57.210 --> 10:59.170
And now let's head over to unity.

11:00.010 --> 11:04.480
So let's head over to unity and we will able to notice.

11:04.760 --> 11:12.880
So for to see that parameter which is a is player in attack range, we need to move over to debug mode

11:13.040 --> 11:15.880
instead of inspector mode to see that.

11:15.880 --> 11:21.840
As you can see, as soon as our skip just gets compiled, we can see the circle just drawn from this

11:21.840 --> 11:29.480
enemy and enemy to game object center position, or from or from this current position of this enemy

11:29.520 --> 11:30.640
to game object.

11:30.800 --> 11:32.840
I want to make it a little bit less.

11:32.880 --> 11:40.080
Basically, I'm gonna down my attack range radius to something like four, and that's pretty much fine.

11:40.080 --> 11:46.840
So once we're gonna get inside of this circle then that is a is player in attack range parameter is

11:46.840 --> 11:47.480
gonna be true.

11:47.520 --> 11:49.360
Else it's gonna be false.

11:49.640 --> 11:53.480
So to check that we can see underneath our enemy to skip.

11:53.480 --> 12:01.000
We're not able to see our the that bool parameter which is is player in attack range since we just made

12:01.000 --> 12:01.840
it private.

12:01.840 --> 12:03.940
So we want to see to see that.

12:03.940 --> 12:06.500
So we need to move over to Inspector in the top right.

12:06.500 --> 12:09.660
We're going to click on it and we're going to choose this debug mode.

12:09.660 --> 12:14.260
And as soon as we have chosen debug we can see private parameters.

12:14.260 --> 12:17.540
And each player in attack range is right over here.

12:17.540 --> 12:20.380
And it's unchecked basically false.

12:20.380 --> 12:26.180
And if we just go ahead and then click on this play button, you will see as soon as we're going to

12:26.180 --> 12:32.300
get inside of this circle of this enemy two game object, this is player in attack range is going to

12:32.300 --> 12:33.860
be true basically means check.

12:33.900 --> 12:37.540
And once we are outside of it, it's gonna be false.

12:37.540 --> 12:38.860
So let's get inside.

12:38.860 --> 12:39.700
As you can see.

12:39.740 --> 12:40.180
Indeed.

12:40.180 --> 12:43.980
But once we get outside of it, it's get unchecked.

12:43.980 --> 12:46.980
But once we get in, we can see it's checked.

12:46.980 --> 12:52.700
Basically just setting it to true or false, or you can simply say check or uncheck.

12:53.020 --> 12:58.420
So we will use this parameter to attack or to stop patrolling.

12:58.420 --> 13:03.220
So let's get out of play mode and let's move over to our Inspector mode.

13:03.220 --> 13:05.930
To do so, let's go over to Inspector one more time.

13:05.930 --> 13:06.770
In the top right.

13:06.770 --> 13:11.610
We're going to click one more time and let's click on this normal in order to go back.

13:11.890 --> 13:15.970
So we will use that parameter which is is player in attack range.

13:16.250 --> 13:19.930
So we will open up our animator script by double clicking on it.

13:20.250 --> 13:27.050
And we're gonna uh so over here as you can notice that we patrolling right over here.

13:27.330 --> 13:31.690
So let's put this, uh, all of this code inside a function.

13:31.690 --> 13:33.210
So let's create a function.

13:33.250 --> 13:37.650
Uh, some we're going to call that function to something like patrolling.

13:37.850 --> 13:40.450
So let's uh for function we're going to type void.

13:40.450 --> 13:42.290
And we have to name the function.

13:42.290 --> 13:46.890
So let's call this function like patrolling or patrol enemy.

13:47.090 --> 13:48.810
Let's call it patrol enemy.

13:48.850 --> 13:51.810
Let's make first bucket and some curly brackets.

13:51.970 --> 13:55.450
And what we want to do, we're going to put all of this line of code.

13:55.450 --> 13:57.410
So this line of code right over here.

13:57.410 --> 14:02.170
As you can see it's moving our uh enemy to game object.

14:02.170 --> 14:07.190
And it's creating the reef in the down direction and then it just flipping itself.

14:07.190 --> 14:10.590
If it's at the at the end of the crown or not.

14:10.590 --> 14:13.910
So this line of code right over here is for trolling.

14:13.910 --> 14:19.590
So when I cut this line of code and we're going to put it inside this petrel enemy function to make

14:19.590 --> 14:25.550
it even simpler or to readable, you can simply say, so we're going to select all of this and we're

14:25.550 --> 14:27.830
going to press down Ctrl X for cut.

14:27.830 --> 14:31.950
And we're going to paste inside this petrel enemy function by Ctrl V.

14:32.270 --> 14:34.630
And now it's done as you can see.

14:34.870 --> 14:38.190
So this seems a lot more cool clean.

14:38.390 --> 14:43.430
And what we have to do now we basically need to call this petrel enemy function.

14:43.430 --> 14:46.470
And this function is just going to patrol our enemy.

14:46.910 --> 14:53.350
But when we need to call it once our uh is player in attack range is true basically means player.

14:53.750 --> 14:54.830
Uh, if uh sorry.

14:55.070 --> 15:00.230
If uh is is player in attack range is false, then we need to call it.

15:00.230 --> 15:07.180
Because if the circle if this if the player inside of this circle, then this enemy two game object

15:07.220 --> 15:08.940
need to stop patrolling.

15:09.100 --> 15:15.860
But if the player game object is outside of this circle, then this enemy two game object need to patrol

15:15.860 --> 15:17.100
around this ground.

15:17.180 --> 15:24.780
So we're going to call this patrol enemy function once our player game object is outside of our circle.

15:24.940 --> 15:26.020
So we're going to check.

15:26.020 --> 15:29.940
So we will use this if condition inside our update function.

15:29.940 --> 15:32.500
Then make first bracket and some curly brackets.

15:32.500 --> 15:34.180
And what we want to check over here.

15:34.180 --> 15:39.780
We basically want to check if is is player a player in attack range.

15:39.780 --> 15:47.860
If it's equals equals to false basically means player is outside of this, of this circle or of this

15:48.100 --> 15:51.060
attack range of this enemy to game object.

15:51.060 --> 15:51.700
Then.

15:51.740 --> 15:54.020
Then what this enemy two game object need to do.

15:54.060 --> 15:55.380
It's need to patrol.

15:55.380 --> 16:02.460
So that's why if it's attack range is player in attack range equals equals to false basically means

16:02.460 --> 16:04.960
player is outside of that circle.

16:05.000 --> 16:11.160
Now what, uh, what, uh, that anime need to anime to game object need to do.

16:11.200 --> 16:12.480
It's need to patrol.

16:12.480 --> 16:17.200
So that's why we're gonna call the function over here, which is patrol enemy.

16:17.360 --> 16:19.880
And we do know this function just going to do these things.

16:19.920 --> 16:21.640
Basically, it's gonna patrol.

16:21.680 --> 16:24.360
Let's suppose if we are attack range.

16:24.360 --> 16:26.520
So we're going to use this else condition.

16:26.560 --> 16:34.800
Else if our player inside of that basically uh, this uh, circle that we created from this enemy two

16:34.800 --> 16:40.760
game object inside of this circle, then this enemy two game object need to stop patrolling.

16:41.080 --> 16:46.280
Uh, so that's why we didn't call inside this else function, which is patrol enemy.

16:46.440 --> 16:48.920
So for now, we're going to print out a message.

16:48.920 --> 16:56.680
So let's type this debug.log in order to print out our message, uh, let's say something like an,

16:56.760 --> 17:03.560
uh, sorry, we will say something like player, player in attack range.

17:03.600 --> 17:05.390
Player in attack range.

17:05.390 --> 17:06.550
Something like that.

17:07.030 --> 17:08.590
Uh, else a else.

17:08.630 --> 17:16.070
Our Is player in in attack range is, uh, true basically means player in inside of this screen uh,

17:16.070 --> 17:19.630
circle that we created from this anime to game object.

17:19.630 --> 17:24.270
Then what we are doing, we simply printing out this message says player in attack range.

17:24.310 --> 17:28.310
Once our Is player in attack range is true, as you can see.

17:28.670 --> 17:36.550
And we do know that if a player in attack range is true true, then we just printing out this message

17:36.590 --> 17:38.350
says player in attack range.

17:38.470 --> 17:45.670
But if the player is outside of that circle, then what we doing as you can see, is player in attack

17:45.670 --> 17:45.990
range.

17:45.990 --> 17:51.670
If it's equals equals to false basically means player game object outside of that circle.

17:51.670 --> 17:54.390
Then we calling the enemy function.

17:54.390 --> 17:57.390
And this function basically patrolling our enemy.

17:57.390 --> 18:04.930
And it's flipping itself according to where a where our enemy to game object is.

18:05.090 --> 18:06.850
So I hope you get the idea.

18:07.010 --> 18:10.170
And now we're going to press down Ctrl S to save our script.

18:10.170 --> 18:12.050
And now let's move over to unity.

18:12.250 --> 18:17.090
You will see as soon as when I get inside of this, uh, attack range.

18:17.130 --> 18:21.570
Radius circle, then this, uh, anime two game object.

18:21.570 --> 18:23.130
Just gonna stop moving.

18:23.530 --> 18:24.130
Stop moving.

18:24.130 --> 18:26.010
And that message just gonna pop up.

18:26.010 --> 18:33.130
But if we not in, then it's, uh, basically our anime two game object just gonna patrol around this

18:33.130 --> 18:33.650
ground.

18:33.650 --> 18:34.890
So let's check that.

18:34.890 --> 18:40.050
So I'm going to select my console tab, and let's click on this play button in the top in order to check

18:40.050 --> 18:40.890
that out.

18:40.890 --> 18:43.050
And we can make it a little bit bigger.

18:43.050 --> 18:51.050
This you can simply say, uh, simply say this circle that we created from this anime to game object.

18:51.050 --> 18:52.370
We can make it bigger.

18:52.370 --> 18:54.410
But before we do, let's have a look.

18:54.450 --> 19:00.930
And now we can see as soon as this player game object collided with this circle that we created from

19:00.930 --> 19:04.840
this anime to game object, this anime two stops moving.

19:04.880 --> 19:10.720
And if we move over to our console tab, we can see a message just getting pop up every single frame

19:10.760 --> 19:12.880
says player in attack range.

19:13.000 --> 19:14.520
So what it's need to do?

19:14.560 --> 19:21.280
Firstly, it's need to get closer to this player game object than it's need to attack.

19:21.280 --> 19:27.840
But once we get outside of this circle, we can see enemy is just patrolling around this ground and

19:27.840 --> 19:30.200
the message just gets stopped popping out.

19:30.200 --> 19:33.920
But once we get in, we can see this player stop.

19:34.080 --> 19:40.320
Sorry, this enemy two game object stops moving and the message just getting pop up says player in attack

19:40.320 --> 19:40.840
range.

19:40.840 --> 19:45.240
So I hope you get the idea that how you can do it and I'm gonna get out of play mode.

19:45.320 --> 19:52.640
And instead of playing the that animation clip, which is the work one we need to attack on this player

19:52.680 --> 19:56.880
game object, uh, so we can just increase our circle.

19:56.880 --> 19:58.760
So I'm gonna increase that.

19:58.760 --> 20:01.280
So let's go over to our enemy two script.

20:01.440 --> 20:06.500
Uh, then, uh, enemy anime to script an attack.

20:06.780 --> 20:09.780
Sorry we didn't given a title.

20:09.780 --> 20:13.660
If I open that up and then attack.

20:14.140 --> 20:20.020
Okay, so we're gonna put down this, uh, ace player attack range.

20:20.020 --> 20:21.380
Something over here.

20:21.900 --> 20:24.540
Attack checking like that.

20:24.540 --> 20:26.220
Let's do it one more time.

20:26.740 --> 20:27.860
Attack checking.

20:28.100 --> 20:32.180
And let's press down Ctrl s to save our script.

20:32.180 --> 20:34.980
And now let's move over to unity.

20:34.980 --> 20:42.980
So the title just gonna pop up underneath our this variable, which is, uh, attack radius, attack

20:42.980 --> 20:44.260
range radius.

20:45.900 --> 20:49.380
So just wait a moment and we will see.

20:49.740 --> 20:50.420
See that?

20:54.180 --> 21:00.300
So now we can see attack checking title just gets pop up.

21:00.420 --> 21:04.860
And I want to bump up the value of this attack range radius.

21:04.890 --> 21:08.570
something around eight, and this seems pretty much cool.

21:08.610 --> 21:09.690
As you can see.

21:10.010 --> 21:12.850
And I will move over to overrides in the inspector.

21:12.850 --> 21:17.170
Then apply all and we can check this out as well.

21:17.170 --> 21:19.210
So I'm going to select my player game object.

21:19.210 --> 21:25.290
And let's drag it a little bit further away from this animated game object for checking purposes.

21:25.290 --> 21:28.050
So I'm going to move it somewhere around here.

21:28.050 --> 21:34.450
So as soon as the circle just gonna collide with this player game object, then this animate just gonna

21:34.490 --> 21:35.170
stop moving.

21:35.170 --> 21:42.050
Because if we move over to our script, as you can see what we're doing, firstly we checking if is

21:42.050 --> 21:49.090
player in attack range is equals equals to false basically means this player is outside of that circle.

21:49.090 --> 21:54.450
So what we're doing in that situation we're just calling the patrolling patrol enemy function.

21:54.450 --> 21:59.130
And this function basically doing these things, basically patrolling our enemy.

21:59.130 --> 22:07.190
But once we get inside of that attack range radius, then as you can see, we printed printing out a

22:07.190 --> 22:14.590
message says player in attack range basically means this player just collided with this enemy to anime

22:14.630 --> 22:18.390
to game object circle, and it's going to stop moving.

22:18.470 --> 22:22.950
We only printing out the message in the console tab as you can notice.

22:22.950 --> 22:29.590
So let's move over to unity and let's click on this play button in the top in order to play our game.

22:29.590 --> 22:30.830
And let's have a look.

22:30.830 --> 22:36.990
So as soon as we're gonna collide with this circle of this enemy two game object, then this enemy two

22:37.030 --> 22:41.350
game object just gonna stops moving and the message just gonna pop up.

22:41.390 --> 22:48.630
As you can see, indeed, this enemy two game object just gets stops and the message just getting pop

22:48.670 --> 22:53.790
up in inside our console tab, we can see player in attack range.

22:53.790 --> 22:55.110
So I hope you get the idea.

22:55.110 --> 22:56.830
So I'm gonna get out of play mode.

22:56.830 --> 23:03.110
And we need to make transition between this animation clip that we created inside this enemy to game

23:03.150 --> 23:03.710
object.

23:03.710 --> 23:06.190
So we need to do that as well.
