WEBVTT

00:00.040 --> 00:06.360
Let's create a enemy script in order to check the distance between our player and this enemy.

00:06.600 --> 00:13.000
So to do that, let's head over to our project tab, then assets folder, and we will head over to our

00:13.000 --> 00:13.960
script folder.

00:14.600 --> 00:18.040
So it's a little bit lagging I really apologize.

00:18.040 --> 00:20.280
So I'm gonna head over to my script folder.

00:20.320 --> 00:24.480
Let's right click there then create a create.

00:24.480 --> 00:27.840
And then you need to move over to scripting right over here.

00:27.840 --> 00:30.240
And then click on this Monobehaviour script.

00:30.400 --> 00:33.680
And you can name that script to something like anime one.

00:33.880 --> 00:38.800
I already created a anime one script, as you can notice right over here.

00:38.800 --> 00:44.200
So I'm going to select my anime one GameObject in the hierarchy, and let's select this anime one script

00:44.200 --> 00:47.960
and let's drag it over to this Add component section in the Inspector.

00:48.160 --> 00:53.600
Or we can simply click on this add component, and we can find the script by typing the name of the

00:53.600 --> 00:56.520
script, which is in our case anime one.

00:56.520 --> 00:59.600
So we can simply type that and it's gonna pop up.

00:59.600 --> 01:01.710
So I hope you get the idea.

01:01.710 --> 01:04.910
So I'm not gonna click on it in order to attach it.

01:05.190 --> 01:09.150
Attach it twice since I already attached, as you can see.

01:09.590 --> 01:14.910
So to get rid of this plus icon we will go over to overrides and then apply all.

01:15.070 --> 01:18.990
And let's open up the enemy one script by double clicking on it.

01:18.990 --> 01:25.510
So what we need first thing we need our player position so we can know that where player is.

01:25.750 --> 01:30.150
And also we're going to create a circle around this enemy one game object.

01:30.310 --> 01:38.230
And if that circle uh, if uh, if our player game object gets inside of that enemy circle, then this

01:38.270 --> 01:45.190
enemy is just gonna shoot out the array on, on top of this player game object and this player game

01:45.230 --> 01:47.310
object just gonna take damage.

01:47.310 --> 01:53.190
So what we're gonna do, uh, firstly, we will create a circle, and also we need player position.

01:53.190 --> 01:57.150
So instead of doing that, let's open up our enemy one script.

01:57.150 --> 02:03.710
And we will create a circle from center position of this anime one game object to create a circle.

02:03.710 --> 02:06.990
We do know that we need to use physics 2D function.

02:06.990 --> 02:12.390
So let's move over to this update function, because we do know that update function runs every single

02:12.390 --> 02:12.990
frame.

02:12.990 --> 02:15.750
So every single frame we need to check the distance.

02:16.350 --> 02:23.950
We need to check if we if our player game object get inside of that circle or collided with that circle

02:23.950 --> 02:24.630
or not.

02:24.910 --> 02:31.230
So to create circle we need to use this physics 2D physics 2D circle function.

02:31.550 --> 02:35.430
And we already use it a couple of times previously.

02:35.430 --> 02:37.790
So we're going to do the same thing basically.

02:37.790 --> 02:40.750
So which is physics 2D dot overlap circle.

02:40.950 --> 02:42.830
So overlap circle.

02:42.830 --> 02:47.750
So as a first argument it's going to take the position from where we want to create the circle.

02:47.750 --> 02:50.030
Second thing it's going to take the radius.

02:50.030 --> 02:52.950
And the third argument it's going to take the layer mask.

02:52.950 --> 02:57.350
So let's go to top of our class and let's assign those variable.

02:57.350 --> 03:00.740
So I'm going to go to top of my Uh, top of my class.

03:00.940 --> 03:04.340
Before we create our variable, let's give it a title.

03:04.340 --> 03:09.700
So we need to type this header, make first bracket, then header in order to give title.

03:09.900 --> 03:14.020
And let's say something like uh circle, uh attack.

03:14.060 --> 03:15.820
Let's simply call it attack.

03:15.820 --> 03:16.820
Something like that.

03:17.060 --> 03:23.540
And so, so what we need, we're going to create our circle center position of that anime game object.

03:23.540 --> 03:25.940
So we don't need any point reference.

03:25.980 --> 03:31.180
Then we can pass a transform dot position which basically means center position.

03:31.180 --> 03:33.740
So the second thing we need which is radius.

03:33.740 --> 03:36.740
So let's make a serialized field private.

03:37.020 --> 03:38.140
Uh, private.

03:38.140 --> 03:41.820
Sorry, this will be private float.

03:41.940 --> 03:45.860
And we can call attack range or attack radius.

03:45.860 --> 03:48.140
Let's call it attack range.

03:48.140 --> 03:52.260
Let's call it attack range instead of calling attack radius.

03:53.020 --> 03:54.140
Attack range.

03:54.140 --> 03:57.900
And by default I'm going to set equal to something like five unit.

03:58.060 --> 04:01.730
And the third argument We need our layer mask.

04:01.730 --> 04:06.370
So let's create a serialized field private layer mask.

04:06.530 --> 04:09.970
And we can call this one damage layer target layer.

04:09.970 --> 04:12.930
Or we can call this one attack layer as well.

04:13.410 --> 04:17.650
Uh, so I'm going to call it uh, something like what is player what.

04:17.770 --> 04:19.970
Since I want to damage my player.

04:19.970 --> 04:24.810
So I'm going to say what is player sorry what is player.

04:24.930 --> 04:27.010
And let's close that up with semicolon.

04:27.010 --> 04:31.810
And now move over to this update function and let's remove these two slashes.

04:31.810 --> 04:36.490
So the first thing it's going to take the position from where we want to create the circle.

04:36.490 --> 04:42.250
So we will create the circle center position of this enemy game object uh enemy one game object.

04:42.250 --> 04:46.010
So we will simply move over to this transform and then position.

04:46.210 --> 04:47.610
So let's do it.

04:47.610 --> 04:53.170
So we're going to pass transform dot position basically means center position of that enemy.

04:53.410 --> 04:55.610
Second thing it's going to take the radius.

04:55.610 --> 04:58.330
So we will pass our attack range.

04:58.530 --> 05:03.480
So instead of calling attack range, we let's call it attack range radius.

05:03.480 --> 05:04.560
It's going to be fine.

05:04.560 --> 05:07.240
So let's call it attack range radius.

05:07.240 --> 05:10.120
So I'm going to put it over here as well.

05:10.320 --> 05:12.680
Range radius.

05:12.680 --> 05:13.880
And now that's fine.

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

05:16.920 --> 05:20.400
So we will pass our what is layer and what is layer.

05:20.400 --> 05:23.200
We're going to choose later our player layer.

05:23.200 --> 05:28.880
And before we choose our player layer we need to assign our player as a player layer mask.

05:29.120 --> 05:32.240
So this function is going to draw the circle.

05:32.520 --> 05:37.320
Or it's going to create the circle around center position of that enemy game object.

05:37.560 --> 05:43.520
And if that circle collide with this player then what we want to do we want to damage it.

05:43.920 --> 05:48.960
So basically this enemy need to play that animation clip which is firing arrow.

05:48.960 --> 05:50.920
For now let's print out a message.

05:51.040 --> 05:55.040
So firstly we will store the result into another variable.

05:55.040 --> 06:00.600
So this function right over here we do know it's going to give a true or false value, depending upon

06:00.600 --> 06:04.840
if the circle is really colliding with this player game object or not.

06:04.880 --> 06:07.240
For now, we're going to print out a message.

06:07.240 --> 06:10.120
So we will we will store the information.

06:10.360 --> 06:13.040
So let's create a collider 2D.

06:13.080 --> 06:14.600
This is going to be Collider 2D.

06:14.640 --> 06:15.120
Why?

06:15.360 --> 06:19.360
Because this over here it's going to work like Collision or Collider.

06:19.360 --> 06:25.040
So that's why we need to put it a in a container or in a variable with the same type.

06:25.040 --> 06:29.640
And we can call this one call info or collision information.

06:29.640 --> 06:31.680
And let's set equal to this.

06:31.680 --> 06:37.840
So this call info can be true or false depending upon if the circle is colliding with this player game

06:37.880 --> 06:39.040
object or not.

06:39.800 --> 06:43.680
So what we're going to do now we're going to use this if condition.

06:43.720 --> 06:46.920
And let's make first bracket and some curly brackets.

06:46.920 --> 06:48.760
And what we want to check over here.

06:48.760 --> 06:52.760
We basically want to check if our call info is true.

06:52.800 --> 06:57.040
If call info is equals equals to true something like this.

06:57.080 --> 06:58.790
Or you can just leave it like this.

06:58.830 --> 07:04.750
It's also basically means to, if that is the case, basically means our circle is just colliding with

07:04.750 --> 07:06.230
this player game object.

07:06.550 --> 07:12.470
Then what we want to do, we basically want to damage our player for now, or we're gonna shoot out.

07:12.510 --> 07:12.950
Ray.

07:13.110 --> 07:13.550
Sorry.

07:13.590 --> 07:21.110
Shoot out our, uh, arrows from that enemy one game object to our to, uh, to our player game object

07:21.110 --> 07:25.430
on top of our player game object in order to damage our player.

07:25.710 --> 07:27.550
For now, we're going to print out a message.

07:27.550 --> 07:29.830
So we're going to type this debug dot log.

07:30.190 --> 07:33.790
And let's say something like let's make quotation.

07:33.790 --> 07:36.630
So debug dot log sorry.

07:36.910 --> 07:42.470
And let's say something like that damaging or shoot uh fire.

07:42.750 --> 07:48.870
Let's say something like fire uh fire arrow, arrow.

07:48.870 --> 07:53.870
And top of that I'm going to add the name of the game object that circle collided with.

07:53.870 --> 08:00.100
So we're going to use this collision call info parameter in order to extract information like the name

08:00.100 --> 08:06.900
of the game object the circle collided with or the circle collided with, or anything we can extract

08:06.900 --> 08:08.900
with this call info parameter.

08:08.900 --> 08:10.660
So let's head over to script.

08:10.660 --> 08:14.980
So we're going to use this call info dot GameObject dot name.

08:15.220 --> 08:17.620
And let's close that up with semicolon.

08:17.620 --> 08:22.740
So call info dot GameObject basically means the GameObject the circle collided with.

08:22.740 --> 08:25.740
So if the circle collided with this player game object.

08:25.740 --> 08:29.780
So they're basically collision dot GameObject means this player GameObject.

08:29.780 --> 08:35.220
And after that we just accessing the name of the game object, which in our case will be player.

08:35.220 --> 08:37.620
So as you can see in Inspector.

08:37.620 --> 08:42.180
So the message in the console tab should pop up Fire Arrow.

08:42.180 --> 08:44.540
And the name of the game object is player.

08:44.540 --> 08:46.660
So Fire Arrow on player.

08:46.700 --> 08:54.020
Let's instead of saying Fire arrow we're gonna say fire arrow on a name of the game object, which is

08:54.020 --> 08:54.620
player.

08:54.620 --> 09:00.700
So the message should be pop up in our console tab says something like fire arrow on player.

09:00.700 --> 09:03.780
And now we're going to press down Ctrl S to save our script.

09:03.780 --> 09:05.740
And now let's move over to unity.

09:08.220 --> 09:10.460
So just wait a little moment.

09:22.300 --> 09:23.580
So just wait.

09:24.020 --> 09:30.380
Basically doing the same thing as we have done with player attack once we created that attack function

09:30.380 --> 09:32.020
as you've seen earlier.

09:32.340 --> 09:38.500
So we just approaching the in the same way and we will use it multiple times.

09:38.820 --> 09:42.460
Uh, we will uh gonna talk about it later.

09:42.460 --> 09:47.940
For now, what we have to do, we need to assign our player as a player layer.

09:47.940 --> 09:54.820
And also, it would be nice if we able to see our circle that we created from center position of this

09:54.860 --> 09:58.610
enemy, one game object as you've seen in the code.

09:58.610 --> 10:04.970
So we basically have to, uh, basically need to make, uh, that draw.

10:04.970 --> 10:10.290
So we're going to use that on draw Ismost selected function, which is unity in build function.

10:10.530 --> 10:17.330
And I really apologize for it's taking a little bit longer time because my system, you know, it's

10:17.330 --> 10:18.330
a little bit slow.

10:18.330 --> 10:23.170
So that's why it's taking a little bit longer time than as usual.

10:23.170 --> 10:29.450
But if you have a fast system then in your case it's just gonna do within, uh, some seconds.

10:30.050 --> 10:35.530
So just wait a moment till I can explain what we can do later.

10:35.730 --> 10:42.090
So now it's a compile, and, uh, so just hold on a little bit.

10:42.130 --> 10:43.410
Now it's compile.

10:43.410 --> 10:49.850
But the problem is that we're not able to see our circle, so it would be nice if we able to see our

10:49.850 --> 10:50.530
circle.

10:50.530 --> 10:56.520
And we do know that in order to create the circle or to draw the circle, we need to use on draw drug

10:56.520 --> 10:58.080
is most selected function.

10:58.080 --> 11:03.600
So let's open up our anime one script one more time, and let's move over to in the bottom.

11:03.600 --> 11:05.160
And we can do it anywhere.

11:05.200 --> 11:07.080
You anywhere we like.

11:07.120 --> 11:12.720
It doesn't need to be in order, but let's do it in the bottom somewhere over here.

11:12.720 --> 11:14.760
So the function is on draw.

11:15.280 --> 11:20.080
So on on draw is most selected function.

11:20.400 --> 11:26.880
So this function right over here, it's gonna take uh basically uh whatever we want to draw, we can

11:26.880 --> 11:28.640
do inside this function.

11:28.640 --> 11:37.680
So to draw a circle we need to use this gizmos gizmos dot draw where sphere function and this function

11:37.680 --> 11:38.760
as a first argument.

11:38.760 --> 11:41.800
It's going to take the position from where you want to draw.

11:41.920 --> 11:46.280
So we're going to draw the circle center position of that anime one game object.

11:46.280 --> 11:48.680
So we will pass Transform.position.

11:48.720 --> 11:54.800
It's basically means current position of that anime game object or center position of that anime, one

11:54.800 --> 11:55.640
game object.

11:55.640 --> 11:58.030
And the second thing it's going to take the radius.

11:58.030 --> 12:01.030
So we will pass our attack range radius.

12:01.030 --> 12:03.110
And let's close that up with semicolon.

12:03.110 --> 12:07.830
And we also can choose a color before the color we would like to draw with.

12:07.830 --> 12:11.070
So we can simply use this gizmo dot color.

12:11.070 --> 12:14.270
And we can set the color equal to that you like.

12:14.270 --> 12:16.830
So I'm going to draw with yellow color a yellow color.

12:16.830 --> 12:19.990
So I'm going to say something like color dot yellow.

12:20.150 --> 12:22.390
And let's close that up with semicolon.

12:22.390 --> 12:23.710
And now this is fine.

12:23.910 --> 12:28.790
And we can simply press down Ctrl s on our keyboard in order to save it.

12:28.790 --> 12:30.670
And we can move over to unity.

12:30.790 --> 12:37.150
And as soon as our ship just gonna compile, you will able to notice the circle will be drawn from that

12:37.150 --> 12:42.990
enemy one game object center position with our attack range radius.

12:50.790 --> 12:51.790
So just wait.

12:52.070 --> 12:58.670
And we don't need to use, uh, basically we don't need to use assigning since we're just drawing from

12:58.670 --> 12:59.470
center position.

12:59.470 --> 13:00.270
So that's why.

13:01.790 --> 13:05.230
Um, so basically we're not going to get any error.

13:05.230 --> 13:10.110
As you can see, as soon as our skip gets compiled, we can see our circle.

13:10.310 --> 13:15.790
And if we move over to anime one script in Inspector, we can see what is player is nothing.

13:15.790 --> 13:17.630
So we will choose our player.

13:17.630 --> 13:21.590
But we don't have any player layer, so we need to create that.

13:21.590 --> 13:25.030
So we will select our player GameObject in the hierarchy first.

13:25.030 --> 13:26.590
Then go over to Inspector.

13:26.590 --> 13:28.510
In the top right we can see layer.

13:28.510 --> 13:31.030
So let's click on this uh default.

13:31.030 --> 13:34.910
Then click on Add Layer and name the layer whatever you want.

13:34.910 --> 13:36.070
So this will be player.

13:36.070 --> 13:37.430
So I'm going to call it player.

13:37.430 --> 13:38.590
Let's hit enter.

13:38.590 --> 13:42.070
And let's select our player game object one more time in the hierarchy.

13:42.190 --> 13:45.990
And let's assign with the layer with which we recently created.

13:45.990 --> 13:47.470
So I'm going to assign with player.

13:47.630 --> 13:50.990
And I'm going to click on this no this game object only.

13:51.030 --> 13:57.460
Basically I want this player only I don't want in this ground check or this attack point.

13:57.460 --> 14:02.860
And you can see in the inspector layer is default in this attack point and this ground check.

14:02.860 --> 14:09.180
But if we choose our player, we can see we assign it this player as a player layer in Inspector we

14:09.180 --> 14:09.940
can notice.

14:09.940 --> 14:16.340
And now we will select our enemy one game object and and in our attack what is player.

14:16.340 --> 14:17.980
We will choose our player.

14:17.980 --> 14:21.500
So the circle just only going to check with this player layer.

14:21.620 --> 14:26.860
I'm going to drag it a little bit far away from this enemy one game object my player.

14:26.860 --> 14:31.580
So let's select our player in the hierarchy and let's select the move tool in this in view.

14:31.580 --> 14:34.100
And let's move it somewhere around here.

14:34.460 --> 14:40.300
And now if we select our console tab and then click on this play button, you will see as soon as we're

14:40.300 --> 14:46.780
gonna collide with this yellow circle or the circle that we created from this enemy, one game object,

14:46.820 --> 14:53.260
the message just going to pop up in the console says, uh, fire on, uh, fire arrow on.

14:53.260 --> 14:55.770
And the name of the game object, which is player.

14:55.770 --> 14:58.650
So if we get collide with this circle.

14:58.690 --> 15:03.490
As you can see, as soon as we just overlapped or collided with this circle.

15:03.650 --> 15:10.530
We can see in our console tab a message just pop up says Fire Arrow on, and the name of the game object

15:10.530 --> 15:12.770
and the name of the game object is player.

15:12.770 --> 15:18.090
So that's why the message just getting pop up is saying fire arrow on player.

15:18.250 --> 15:19.330
As you can see.

15:19.650 --> 15:26.530
So now instead of printing out message, this player, this enemy, one need to play that enemy arrow

15:26.530 --> 15:28.810
fire animation clip as you seen.

15:29.250 --> 15:35.810
So basically what we have to do, we need a reference of this animator component of this enemy one game

15:35.850 --> 15:36.370
object.

15:36.370 --> 15:40.890
So if we select our enemy one in the hierarchy, then move over to Inspector.

15:40.890 --> 15:45.930
We can see an animator component is attached to this enemy one game object.

15:45.930 --> 15:52.810
And we do know that this component is responsible for playing our animation, switching animation and

15:52.810 --> 15:53.690
all of this.

15:53.690 --> 15:59.000
So let's get out of play mode and we need to grab the reference of this animator component.

15:59.120 --> 16:00.200
So let's do it.

16:00.200 --> 16:02.400
And let's clear all of the messages.

16:02.400 --> 16:07.120
Instead of printing out message we need to set that parameter.

16:07.120 --> 16:11.760
So if I select my anime one inch the hierarchy move over to my animator tab.

16:11.760 --> 16:15.440
So we basically need to set this in range parameter to true.

16:16.240 --> 16:23.400
But before we do we need a reference of this animator component and we will grab it in through our start

16:23.400 --> 16:24.040
function.

16:24.240 --> 16:27.480
And after that we will set this parameter which is in range.

16:27.480 --> 16:33.640
And we do know that if we set this in range parameter to true, it's just going to play that animation

16:33.640 --> 16:40.640
clip which is a fire arrow animation over again and again of this anime one game object.

16:40.640 --> 16:46.640
So let's open up our anime one script by double clicking on it, and let's go to the top of our class

16:46.640 --> 16:48.480
and let's grab the reference first.

16:48.640 --> 16:53.520
And that doesn't need to be public, so we can make it private instead.

16:53.520 --> 16:54.960
State, uh, private.

16:54.960 --> 16:57.760
And the component we're looking for is animator.

16:57.760 --> 17:02.400
So we're going to type this animator and let's call this one animator.

17:02.400 --> 17:04.720
And let's close that up with semicolon.

17:04.720 --> 17:07.400
And now let's move over to this start function.

17:07.400 --> 17:10.520
So this start function get call in the start of the game.

17:10.520 --> 17:13.640
So in this start of the game we're just gonna grab the reference.

17:13.640 --> 17:21.720
So we will set our animator equal to this dot object dot get component.

17:21.720 --> 17:24.320
And the component we're looking for is animator.

17:24.320 --> 17:29.600
So inside these arrows we need to pass the component name which in our case animator.

17:29.640 --> 17:33.080
Let's make first bracket and then close that with semicolon.

17:33.080 --> 17:35.560
So this dot game object dot get component.

17:35.560 --> 17:38.800
Basically it just reference referencing itself.

17:38.960 --> 17:42.840
So the anime one script is attached to this anime one game object.

17:42.840 --> 17:47.320
So this dot game object basically means this anime, one game object itself.

17:47.320 --> 17:53.320
And then we just using get component and the component we're getting this animator as you can see.

17:53.550 --> 17:59.310
So basically we're just taking that animator component of this anime one, this one, and we're storing

17:59.310 --> 18:01.150
into this animator variable.

18:01.190 --> 18:02.150
As you can see.

18:02.470 --> 18:05.990
So now we have the reference of that animator component.

18:05.990 --> 18:13.550
And we are ready to are ready to play that animation clip, which is uh, which, which, you know,

18:13.750 --> 18:14.630
fire arrow.

18:14.630 --> 18:18.870
So instead of printing out passage we need to set that in range parameter.

18:18.870 --> 18:23.270
So firstly what we have to do, we need to move over to our animator component.

18:23.270 --> 18:28.670
And we're going to use this set bool function as in order to set the full parameter.

18:28.670 --> 18:32.590
So as you know that in range parameter was bool parameter.

18:32.590 --> 18:35.630
So that's why we need to use this set bool function.

18:35.630 --> 18:41.470
So firstly we just moving over to animator component and then we're using dot set bool function.

18:41.470 --> 18:43.710
And this function as a first argument.

18:43.710 --> 18:46.270
It's going to take in quotation the parameter name.

18:46.430 --> 18:49.150
So in quotation uh the parameter name.

18:49.150 --> 18:52.390
So the parameter name is and in range.

18:52.790 --> 18:56.620
So make sure you, uh, spell it correct in range.

18:56.620 --> 18:59.420
And the second thing, comma, it's going to take the value.

18:59.420 --> 19:01.740
So we will set it to true basically means checked.

19:01.740 --> 19:02.460
And we do not.

19:02.460 --> 19:09.180
Once we set it it's going to play the, uh, fire arrow animation clip of that anime one game object

19:09.180 --> 19:11.100
over again and again.

19:11.100 --> 19:12.700
So we will set it to true.

19:12.700 --> 19:14.820
And now let's close that up with semicolon.

19:14.820 --> 19:17.660
And let's press down Ctrl S to save our escape.

19:17.700 --> 19:19.620
And now let's move over to unity.

19:19.620 --> 19:24.900
So firstly what we're doing we're just going over to this animator component of this anime one game

19:24.940 --> 19:25.500
object.

19:25.500 --> 19:32.100
And after that we just setting this in range parameter, as you can see in animator tab.

19:32.100 --> 19:35.700
And we're setting it to true uh, means equal means check.

19:35.700 --> 19:37.580
And we do not want we're gonna set it.

19:37.620 --> 19:44.660
It's gonna play that animation clip which is the attack arrow fire arrow fire animation clip over again

19:44.660 --> 19:45.500
and again.

19:45.500 --> 19:49.180
So let's click on this play button and let's collide with this circle.

19:49.180 --> 19:56.460
And as soon as we're gonna collide with that you will see this in range parameter which is setting it

19:56.460 --> 19:57.020
to true.

19:57.060 --> 20:01.060
Means take and and our enemy one.

20:01.060 --> 20:04.540
Just going to play that animation clip over again and again.

20:04.660 --> 20:07.700
So now if I collide with this circle you will see.

20:08.020 --> 20:09.220
So just wait.

20:09.220 --> 20:10.820
It's lagging a little bit.

20:10.820 --> 20:17.140
So as you can see, as soon as we just colliding with this, uh, circle of this enemy one game object.

20:17.140 --> 20:24.060
Enemy one just playing that, uh, arrow fire animation clip over again and again.

20:24.060 --> 20:27.300
And you can take a look in animator tab as well.

20:27.740 --> 20:34.580
But the problem is that if we don't collide with this, uh, this circle of this enemy, one that we

20:34.620 --> 20:41.780
created, still this enemy one just playing that arrow fire animation clip over again and again.

20:41.780 --> 20:43.420
So we need to stop playing that.

20:43.420 --> 20:47.780
Instead, we need to play the idle animation clip of this enemy one.

20:47.780 --> 20:53.490
So basically what we need to do, we basically need to set back this in range parameter to false, and

20:53.490 --> 20:56.770
we can see as soon as we set it to false or uncheck.

20:56.810 --> 21:01.810
Now this enemy one is playing the idle animation clip over again and again.

21:01.850 --> 21:02.290
Why?

21:02.490 --> 21:07.370
Because if we select the back transition and go over to Inspector, scroll down to.

21:07.410 --> 21:07.890
Condition.

21:07.890 --> 21:10.850
We can see that we have chosen that condition.

21:10.850 --> 21:16.770
If in range is false, then it's going to play the idle animation clip over again and again.

21:16.770 --> 21:20.170
So we need to set back this in range parameter to false.

21:20.330 --> 21:22.730
Uh, false through our code.

21:22.730 --> 21:27.370
Once we not colliding with this enemy circle that we created.

21:27.370 --> 21:31.090
So let's get out of play mode and let's move over to our script.

21:31.090 --> 21:37.610
And over here, as you can see, if call info true basically means the circle colliding with that player

21:37.650 --> 21:38.450
game object.

21:38.690 --> 21:40.930
Uh, else if our circle.

21:40.930 --> 21:42.450
So else we're going to use.

21:42.450 --> 21:46.930
Let's make a curly brackets and we will, uh, do it over here.

21:46.930 --> 21:49.730
We basically want to check else our circle.

21:50.010 --> 21:54.520
Uh, basically else our player is not colliding with this enemy circle.

21:54.520 --> 21:59.520
Then what this enemy one needs to do is need to play that ideal animation clip.

21:59.560 --> 22:03.280
Basically, we need to set back this in range parameter to false.

22:03.520 --> 22:05.040
So let's go to a script.

22:05.040 --> 22:07.800
So we will go to animator component first.

22:07.840 --> 22:12.360
Then we're going to use this set bool function animator and set bool.

22:12.520 --> 22:15.360
And as a first argument it's in quotation.

22:15.360 --> 22:17.240
It's going to take the parameter name.

22:17.240 --> 22:19.600
And the parameter name is in range.

22:19.600 --> 22:21.640
And make sure you spelling it correct.

22:21.680 --> 22:24.800
Second thing it's going to take the value that you want to set.

22:24.800 --> 22:27.240
So we're going to set it to false false.

22:27.240 --> 22:29.120
Or you can simply say uncheck.

22:29.200 --> 22:31.760
And now we will close that off with semicolon.

22:31.880 --> 22:37.760
And if we save our script and move over to unity, you will see as soon as we're going to leave this

22:37.760 --> 22:45.600
Collider 2D that we created from this enemy, one GameObject basically gets outside of it, this enemy

22:45.600 --> 22:46.000
one.

22:46.040 --> 22:52.590
Now we're gonna play that idle animation clip instead of the arrow fire over again and again.

22:52.630 --> 22:52.990
Why?

22:53.030 --> 22:59.150
Because we checking that if call info is false basically means we're not colliding with this circle.

22:59.390 --> 23:01.830
So now let's check it.

23:01.830 --> 23:06.830
To check that, let's click on this play button in the top in order to play our game.

23:06.830 --> 23:08.630
And let's take a look on this.

23:08.710 --> 23:15.270
So as soon as we collide with this circle of this enemy one, this we setting this in range parameter

23:15.270 --> 23:21.550
to true basically means we just playing that arrow fire animation clip over again and again.

23:21.790 --> 23:26.910
So if I collide with this circle, as you can see, it's now playing over again and again.

23:26.910 --> 23:33.950
But as soon as we leave this circle, we can see by now this enemy one is now playing the idle animation

23:33.950 --> 23:36.190
clip instead of the arrow fire.

23:36.350 --> 23:42.070
And we can take a look in animator tab as well, but make sure you select your enemy one GameObject

23:42.070 --> 23:46.390
in the hierarchy first, then move over to animator tab and you can see.

23:46.590 --> 23:52.590
So as soon as we collide with this circle, it's now playing Arrow Fire and once we leave it, it's

23:52.590 --> 23:58.710
playing that ideal because once we leave it, we do know that we're just setting back this inrange parameter

23:58.710 --> 24:02.190
to false via our scripting, as you seen.

24:02.190 --> 24:03.670
So I'm going to get out of play mode.

24:03.670 --> 24:06.710
So I hope you get the idea that how you can do it.

24:06.990 --> 24:09.550
And let me explain one more time.

24:09.550 --> 24:13.470
So if I move over to my script, as you can see over here.

24:13.470 --> 24:17.750
So firstly we're creating that circle from our enemy center position.

24:17.750 --> 24:23.790
And we're checking firstly if circle colliding basically means if call info is true means that circle

24:23.790 --> 24:29.430
is colliding with that player game object, then we're just going over to animator component of our

24:29.470 --> 24:33.550
enemy one game object, and then setting that in range parameter to true.

24:33.750 --> 24:40.590
But once the circle is not colliding with that player, then what we doing else we doing, we just moving

24:40.590 --> 24:48.710
over to animator component and we setting that in range parameter to false as you can see uncheck.

24:48.710 --> 24:51.750
So I hope you get the idea that how you can do it.
