WEBVTT

00:00.020 --> 00:00.410
Hello guys.

00:00.410 --> 00:01.340
Welcome to the video.

00:01.340 --> 00:05.540
Even though we can consider this project as completed, I still want to show you some things that you

00:05.540 --> 00:07.160
could do to improve the game.

00:07.160 --> 00:12.950
And I think making flying enemies is a great practice for your 2D development skills.

00:12.980 --> 00:13.550
All right.

00:13.550 --> 00:19.310
Because these things, they are pretty simple, but it takes the skill to make it simple and to make

00:19.310 --> 00:20.510
it work as you want it.

00:20.510 --> 00:26.030
So I offer you to sort of complete this section as well, because this is a great practice for you.

00:26.030 --> 00:30.380
I believe that's what I think we're going to start by making very interesting flying enemy.

00:30.380 --> 00:32.420
It's going to be enemy bat.

00:32.420 --> 00:34.790
Let's go to graphics enemies.

00:34.790 --> 00:41.690
Bat I'm going to take this sprites and I'm going to change pixel per unit to 16 or I already have it.

00:41.690 --> 00:42.560
It's okay.

00:42.830 --> 00:47.420
Now we're going to go to Asset Prefabs enemies.

00:47.420 --> 00:50.600
We're going to take enemy mushroom and we're going to change it.

00:50.600 --> 00:52.100
So it's going to be a bat.

00:52.250 --> 00:54.830
Let's do prefab unpack completely.

00:56.220 --> 00:59.370
Let's change the name to, uh, bed.

01:00.710 --> 01:07.940
And then we want to remove the script because we need an embed script and we need animator, right.

01:07.940 --> 01:09.020
This is what we need.

01:09.020 --> 01:12.980
Let's go to Asset Graphics enemies.

01:12.980 --> 01:15.950
Bat we're going to go to Sprite Renderer.

01:16.040 --> 01:18.500
Take the idle place it over here.

01:18.830 --> 01:19.460
Very nice.

01:19.460 --> 01:21.110
So this is the flying enemy.

01:23.570 --> 01:26.390
Uh, we need to adjust colliders, but we're going to do that later.

01:26.390 --> 01:33.230
As of now, we want to go to rigid body and change body type to kinematic because we still want it to

01:33.230 --> 01:37.250
move around, but we don't want it to use gravity or anything else.

01:37.250 --> 01:41.360
We want to move object with the move towards functionality.

01:42.690 --> 01:44.940
So that's why we're using it as kinematic.

01:45.420 --> 01:47.910
Then we're going to close this.

01:47.910 --> 01:51.330
Close this and let's go to asset scripts.

01:51.600 --> 01:52.560
Enemies.

01:53.380 --> 01:54.730
We're going to make.

01:56.060 --> 01:58.160
Enemy bet.

02:01.850 --> 02:04.070
Let's put it on the enemy.

02:05.330 --> 02:06.440
Like that.

02:06.440 --> 02:09.380
And, uh, we're going to take care of this later.

02:09.380 --> 02:12.530
As of now, let's do animations and animator setup.

02:12.980 --> 02:18.770
We're going to go to animations enemies, and over here we need to fix something on the plant.

02:18.770 --> 02:20.810
We need to rename this to enemy.

02:21.870 --> 02:22.560
Planned.

02:24.300 --> 02:24.780
AC.

02:25.050 --> 02:27.360
Okay, now let's go back to the folder.

02:28.250 --> 02:29.780
And make a folder.

02:32.070 --> 02:34.680
Bet we can go inside of this.

02:34.800 --> 02:37.470
We need animator controller.

02:38.890 --> 02:41.530
I'm going to name it as Enemy Bad AC.

02:43.120 --> 02:45.310
We're going to drag it over here.

02:45.310 --> 02:48.130
And now we are ready to create a bunch of animations.

02:48.460 --> 02:54.610
We're going to go to animation Window, click create and we're going to have Anime Bed idle.

02:56.620 --> 02:57.730
Let's go to graphics.

02:57.730 --> 02:59.290
Enemies bed.

02:59.650 --> 03:01.090
Let's take the idle.

03:01.090 --> 03:02.170
Drag it here.

03:02.170 --> 03:04.060
Sample rate 20.

03:04.630 --> 03:06.160
Let's make another one.

03:07.240 --> 03:07.870
Enemy.

03:07.870 --> 03:09.640
Bad move.

03:09.670 --> 03:10.810
We're going to take the fly.

03:10.810 --> 03:11.830
Animation.

03:13.240 --> 03:14.440
Drag it here.

03:14.440 --> 03:16.150
Sample rate 20.

03:16.900 --> 03:18.220
We also need.

03:20.030 --> 03:21.770
Enemy bet.

03:22.600 --> 03:23.140
Hit.

03:24.460 --> 03:25.600
Gonna take the heat.

03:25.600 --> 03:26.650
Drag it here.

03:26.650 --> 03:28.060
Sample rate 20.

03:29.870 --> 03:33.230
And we need the sealing in and sealing out.

03:33.260 --> 03:39.740
These animations are used to make bat fly off the ceiling and then in the ceiling, but I want to name

03:39.740 --> 03:40.940
them as.

03:41.660 --> 03:42.710
Enemy.

03:44.160 --> 03:45.690
But fly out.

03:48.150 --> 03:49.650
Let's take the ceiling out.

03:49.650 --> 03:50.880
Sample rate 20.

03:51.420 --> 03:52.830
And this is how it looks.

03:54.840 --> 03:56.700
So it flies off the ceiling.

03:57.690 --> 04:01.500
And then there is one more enemy bat fly in.

04:02.740 --> 04:05.980
You're going to take this and drag it over here.

04:05.980 --> 04:07.960
Sample rate 20.

04:08.560 --> 04:11.440
Fly in is going to land on the ceiling.

04:12.210 --> 04:12.810
Very nice.

04:12.810 --> 04:15.840
Now let's select the enemy bed and go to animator.

04:16.650 --> 04:18.870
And over here we need to do a bit of a setup.

04:20.210 --> 04:25.550
So we want to move from idle to move animation, but not immediately.

04:25.580 --> 04:29.300
First we want to trigger fly out animation and fly in.

04:29.810 --> 04:31.340
So we're going to make parameter.

04:32.320 --> 04:33.520
Uh, is moving.

04:36.490 --> 04:38.860
And over here we're going to transfer to fly out.

04:38.860 --> 04:43.720
If is moving through with unchecked exit time and no transition duration.

04:43.720 --> 04:49.990
But when we transfer to move, we want to have exit time one, transition duration zero.

04:50.320 --> 04:51.280
Just like that.

04:53.070 --> 04:56.400
Then we transfer from move to fly in.

04:57.100 --> 05:00.520
With uh, is moving poles.

05:00.520 --> 05:03.940
Transition duration zero, exit time unchecked.

05:04.210 --> 05:06.910
Then we transfer into idle from flying.

05:07.000 --> 05:08.290
So we moved.

05:08.290 --> 05:11.530
We flied into the ceiling and we transfer into idle.

05:11.530 --> 05:12.910
This is how it's going to be.

05:13.270 --> 05:14.650
The next time should be one.

05:14.650 --> 05:16.750
Transition duration zero.

05:16.750 --> 05:22.390
Regarding this enemy bat hit animation, we can just transfer from any state.

05:23.860 --> 05:25.270
With a trigger.

05:26.100 --> 05:26.640
Heat.

05:27.360 --> 05:28.530
Let's go here.

05:28.530 --> 05:33.870
Make condition trigger exit time and check transition duration zero.

05:35.390 --> 05:35.960
All right.

05:35.960 --> 05:38.270
And let's uncheck controls it to self as well.

05:39.770 --> 05:40.460
Very nice.

05:40.460 --> 05:43.340
Animator is ready and let's go to the script.

05:49.500 --> 05:50.070
Over here.

05:50.070 --> 05:52.170
We want to inherit from the enemy.

05:54.930 --> 05:57.330
And we want a bunch of variables.

05:57.330 --> 06:01.140
So first of all, Bette should have the aggression range.

06:01.140 --> 06:04.080
In this aggression range it will detect the player.

06:04.080 --> 06:10.590
And if it detects the player then it's going to fly to the player, hit him and then fly back to original

06:10.590 --> 06:11.160
position.

06:11.160 --> 06:20.760
From that, we know that we need a private Vector3 original position, and we need private Vector3 destination.

06:20.760 --> 06:26.430
No matter if flying to hit the player or be flying back to original position, we're going to use destination

06:26.430 --> 06:26.910
for that.

06:26.910 --> 06:32.280
Also, we want to have serialized field, private float, aggro radius.

06:32.280 --> 06:37.170
I'm going to make it equal to seven by default, and this is going to be used to detect the player around

06:37.170 --> 06:37.740
the bat.

06:39.240 --> 06:43.980
Maybe let's organize it a bit with a batch details header.

06:44.340 --> 06:46.260
And we want to have.

06:48.040 --> 06:52.570
A boolean that would say if bet can be aggressive, let's make it public for now.

06:52.570 --> 06:56.410
So it's easier for us to debug and be aggressive.

06:56.410 --> 06:59.410
And also we're going to use Collider to detect the player.

06:59.410 --> 07:02.710
So I want to make public Collider 2D target.

07:02.920 --> 07:03.880
Very nice.

07:03.880 --> 07:05.650
Now let's override our weak.

07:06.220 --> 07:07.630
And inside of the awake.

07:07.630 --> 07:14.620
We want to do original position equals to transform position and can move equals to false.

07:14.620 --> 07:19.510
If you remember we have this boolean on enemy script over here.

07:21.940 --> 07:22.690
Okay.

07:22.690 --> 07:29.350
Then we need to override update because it's going to handle, um, movement and player detection.

07:30.010 --> 07:32.170
And we want to override.

07:33.890 --> 07:40.700
Handle animator and remove the base because animator on the enemy updates x velocity and we don't have

07:40.700 --> 07:42.350
it on the bad enemy.

07:46.990 --> 07:53.080
So I'm going to remove base and I'm going to override ondraw gizmos because I want to see radius of

07:53.380 --> 07:54.850
uh, player check.

07:54.970 --> 08:01.570
I'm going to do gizmos draw wire sphere from a transform position in aggro radius.

08:01.690 --> 08:02.230
Okay.

08:02.230 --> 08:03.940
So this is basic setup.

08:03.940 --> 08:06.880
Now let's make the bet detect the player.

08:06.880 --> 08:07.720
That's what I want to do.

08:07.720 --> 08:13.480
First we're going to do private void handle player detection.

08:13.480 --> 08:19.810
And then we're going to check if target is equals to null means we need to look for a target.

08:19.810 --> 08:22.720
And we're going to do that only if we can be aggressive.

08:22.750 --> 08:28.840
Then inside of this method I'm going to try to fill up variable of a target with a constant search of

08:28.840 --> 08:31.480
the collider inside of the circle.

08:31.480 --> 08:39.940
So we're going to do this physic 2D overlap circle from transform position in aggro radius on what is

08:39.940 --> 08:43.060
player layer like that?

08:44.830 --> 08:47.680
And this is going to be constantly called in the update.

08:48.750 --> 08:50.730
Handle player detection.

08:50.730 --> 08:51.750
Let's go and see this.

08:51.780 --> 08:53.010
We just want to try this one.

08:53.010 --> 08:55.560
First we're going to go to unity.

08:57.260 --> 08:57.830
On the scene.

08:57.830 --> 09:00.080
We need to fill up this variable over here.

09:00.080 --> 09:01.340
So what is ground?

09:01.340 --> 09:01.940
Ground?

09:01.940 --> 09:03.710
What is player player.

09:03.710 --> 09:08.690
And actually we don't need ground check on the bat so I think.

09:10.110 --> 09:11.670
Actually, we can just assign it here.

09:11.670 --> 09:12.600
It doesn't matter.

09:12.600 --> 09:13.650
Let's just do it.

09:14.640 --> 09:15.360
And.

09:15.360 --> 09:15.900
Yeah.

09:17.050 --> 09:18.160
Let's see the radius.

09:18.160 --> 09:19.570
So it's pretty small.

09:19.570 --> 09:25.480
I want to do bigger radius so it's easier to check I'm going to do 15 okay.

09:25.720 --> 09:27.520
And let's place it.

09:28.300 --> 09:32.110
Let's do 16 so it's easier for me to walk in the radius.

09:34.110 --> 09:38.130
Okay, so now we can see that Beth can be aggressive.

09:38.860 --> 09:40.810
We just need to check through over here.

09:40.810 --> 09:42.550
And I'm in the game.

09:42.550 --> 09:46.210
That can be aggressive and it has a target that is empty.

09:46.240 --> 09:49.420
Now I'm going to walk into the area and.

09:50.550 --> 09:54.150
It found player as a target, which is just what we need.

09:54.180 --> 09:55.530
You can see it here.

09:55.560 --> 09:57.390
Now we're going to go back to the script.

09:57.390 --> 10:03.990
And once we detected the player we're going to stop detection and we're going to make it move to the

10:03.990 --> 10:04.920
destination.

10:04.920 --> 10:05.370
Right.

10:05.370 --> 10:11.880
So over here if target is not equals to null and it will be done in the same frame as we did assign

10:11.880 --> 10:12.840
target over here.

10:12.840 --> 10:14.520
So this is just what we need.

10:15.370 --> 10:20.950
So if we did that we're going to set destination equals to target transform position.

10:21.100 --> 10:23.920
And we want to say that we cannot be aggressive anymore.

10:23.920 --> 10:25.810
So it can be aggressive false.

10:25.810 --> 10:27.790
Because we want to be aggressive.

10:27.790 --> 10:34.630
Like you know when we detect in the player maybe this one uh better be named as can detect player.

10:34.630 --> 10:34.900
Yeah.

10:34.900 --> 10:37.690
And also we want to change animator parameter.

10:37.690 --> 10:39.820
So that looks like it's flying out.

10:39.820 --> 10:43.810
So I'm going to do anim set bool of is.

10:45.080 --> 10:49.280
Moving to true, he's going to transfer into animation.

10:51.630 --> 10:54.060
Now this is what we need to do to detect the player.

10:54.090 --> 10:56.430
Now let's take care of the movement.

10:56.940 --> 10:59.370
I'm going to go here and make handle.

11:00.850 --> 11:02.860
Handle movement method.

11:02.860 --> 11:06.040
Then I'm going to click Enter Generate method.

11:06.040 --> 11:12.040
And inside of this method of course if Canmove is false we're going to return.

11:12.040 --> 11:13.960
And now we need to set up movement.

11:15.370 --> 11:16.600
Uh, let's do this.

11:16.600 --> 11:19.660
First of all, we want to do flip.

11:19.660 --> 11:23.530
So handle flip according to the destination dot x.

11:23.530 --> 11:26.470
So it will always look on the destination point.

11:26.470 --> 11:30.700
Then we want to take transform position and we want to move it with a vector two.

11:30.700 --> 11:39.040
Move towards from transform position to destination with a move speed multiplied by time dot delta time

11:39.310 --> 11:40.000
okay.

11:41.050 --> 11:43.870
Now it's going to fly to a destination and it's going to work.

11:43.870 --> 11:49.570
But we want to know what is going to happen when we flew close to the destination.

11:49.570 --> 11:50.170
Right.

11:50.380 --> 11:52.060
So we're going to do vector two.

11:53.490 --> 12:00.120
And the distance between transform position and destination, and if it's less than 0.1, means we are

12:00.120 --> 12:01.710
close enough to destination.

12:01.710 --> 12:05.460
And we want to see what is the destination now.

12:05.460 --> 12:09.930
Because if we flew to the player, then it means we can return back to original position.

12:09.930 --> 12:15.150
If we came to original position, then it means we can become aggressive again and we can search for

12:15.150 --> 12:16.350
player again and so on.

12:16.350 --> 12:17.760
So we're going to do this.

12:17.760 --> 12:25.980
If destination is equals to original position, then we're going to say uh can move false.

12:25.980 --> 12:27.510
We want to stop the movement.

12:27.510 --> 12:30.330
And also we can do anim set bool.

12:31.520 --> 12:33.830
Of is moving to false.

12:33.830 --> 12:36.560
So we're going to transfer back to idle animation.

12:36.560 --> 12:44.180
And else if the destination was players position then we're going to do destination equals to original

12:44.180 --> 12:44.750
position.

12:44.750 --> 12:47.420
We're going to make it fly back to the original position.

12:47.870 --> 12:53.330
And also just in case we want to make target equals to null, uh, like that.

12:53.480 --> 12:57.770
Let's save this and let's see what it's going to do now okay.

13:04.790 --> 13:06.680
Okay, so here is the bet.

13:06.710 --> 13:08.510
I'm going to walk into the radius.

13:10.020 --> 13:11.250
And it doesn't care.

13:11.250 --> 13:14.520
Okay, and there is a reason I forgot to make it true by default.

13:14.520 --> 13:15.270
Over here.

13:15.270 --> 13:16.140
Let's do it.

13:19.690 --> 13:24.160
It's almost flying I guess because can move.

13:24.160 --> 13:25.870
Boolean is false.

13:26.110 --> 13:28.930
Let's go to enemy bet and we want to make it true.

13:28.930 --> 13:31.420
But I don't want to make it true immediately.

13:31.420 --> 13:35.380
I want to make it true when we finish animation of line out.

13:35.380 --> 13:39.250
Because when it does the flying out animation, it still supposed to be at one place.

13:39.250 --> 13:47.440
So let's do private void allow movement and this will do just can move equals to true.

13:47.650 --> 13:51.520
And let's go to animation and set trigger with this method.

13:53.890 --> 13:55.690
We're going to take animation of the bed.

13:55.690 --> 13:58.330
Let's find, uh, flying out.

13:58.930 --> 14:06.850
And over here we're going to add event of enemy bed methods allow movement.

14:07.520 --> 14:10.070
Okay, let's go back.

14:10.070 --> 14:11.390
Let's make.

14:12.230 --> 14:13.640
Can detect player true.

14:13.640 --> 14:15.620
And let's go and try again.

14:18.280 --> 14:19.210
Okay.

14:19.570 --> 14:21.610
And it's flying to the player.

14:21.730 --> 14:23.680
Very slow, but it's okay.

14:24.940 --> 14:29.650
And it's going to fly to the last known position of the player, then it's going back.

14:31.630 --> 14:32.890
Let me make it faster.

14:34.140 --> 14:35.640
And stays in idle.

14:35.670 --> 14:36.750
Very cool.

14:36.750 --> 14:38.100
I've seen a bit of a glitch.

14:38.100 --> 14:38.730
I'm going to check.

14:38.730 --> 14:39.990
What is that later on.

14:39.990 --> 14:46.380
As of now, we need to, uh, make reset functionality because now it cannot detect me again.

14:46.380 --> 14:47.580
That's the problem.

14:47.970 --> 14:49.650
Uh, let's go back to the script.

14:52.470 --> 14:55.680
And how we want to do the reset functionality.

14:55.710 --> 15:01.350
First of all, we want it to be in idle for a bit so it will not fly again.

15:01.350 --> 15:02.430
Back to the player.

15:02.430 --> 15:05.130
Some sort of cooldown for that.

15:05.130 --> 15:06.360
We can um.

15:08.060 --> 15:15.380
Go here and make can detect player equals to false when it flew to original destination just to reset

15:15.380 --> 15:18.950
things once again and uh stop player detection.

15:18.950 --> 15:25.850
And then over here in the update I'm going to do if idle timer is less than zero then can detect player

15:25.850 --> 15:26.930
equals to true.

15:27.580 --> 15:32.200
And we just need to set this timer once we came back to original position.

15:32.810 --> 15:37.670
So over here I'm going to do idle timer equals to idle duration.

15:39.250 --> 15:39.970
Okay.

15:39.970 --> 15:42.970
And I believe this should do the job.

15:43.330 --> 15:48.040
Yeah, this was quite fast, but this should be enough.

15:48.190 --> 15:49.330
Let's go back.

15:50.340 --> 15:54.630
And now that we're doing, uh, detection with the idle timer, it doesn't matter.

15:54.630 --> 15:55.680
It is true or false.

15:55.680 --> 16:00.060
So over here, um, because it's going to just reset itself automatically.

16:00.750 --> 16:02.460
Okay, so we can detect the player.

16:02.460 --> 16:03.960
I'm going to give it speed of ten.

16:03.960 --> 16:08.670
So it's going to be faster to check offline to me trying to hit me.

16:09.060 --> 16:09.690
Oh no.

16:09.690 --> 16:10.500
Oh no.

16:11.060 --> 16:11.510
Man.

16:11.510 --> 16:11.990
That's what.

16:13.270 --> 16:15.670
Man, that was aggressive.

16:16.390 --> 16:18.700
So, uh, what was wrong there?

16:19.030 --> 16:20.290
All right, so what is happening?

16:20.290 --> 16:21.940
There is something very simple.

16:22.240 --> 16:25.330
Um, over here, we are looking for target.

16:25.330 --> 16:28.300
If target is equals to null and we can detect the player.

16:28.300 --> 16:34.090
And that happens simply because we make target equals to null over here when we reach the destination.

16:34.090 --> 16:35.020
That was a player.

16:35.020 --> 16:38.470
So let's take this line of code and let's move it over here.

16:38.470 --> 16:40.030
And this one will solve the issue.

16:40.030 --> 16:40.510
Now.

16:40.510 --> 16:41.470
Very good.

16:41.470 --> 16:42.550
Let's save this.

16:42.550 --> 16:43.570
Let's go back.

16:46.190 --> 16:51.710
I'm going to change move speed of the bed to 15 so it flies faster and we can check stuff.

16:51.830 --> 16:54.260
And I'm going to go into radius.

16:54.260 --> 16:57.020
It flies there, goes back, waits.

16:57.590 --> 16:59.930
Then when I enter again flies there.

16:59.930 --> 17:01.730
Goes back, waits.

17:02.540 --> 17:03.980
Okay.

17:04.660 --> 17:05.560
Very nice.

17:05.560 --> 17:09.790
Now I can see a bit of a glitch with the animation over there when it flies in.

17:09.790 --> 17:12.760
That happens because we have a loop on the animations.

17:12.760 --> 17:15.790
So let's go back to asset animations.

17:15.790 --> 17:17.590
Enemy bat.

17:17.740 --> 17:22.300
There is this fly in, fly out and hit and we can uncheck loop time.

17:22.540 --> 17:23.590
Very good.

17:23.710 --> 17:25.150
Let's go back to the script.

17:25.150 --> 17:27.700
And now I want to add one more improvement.

17:27.700 --> 17:33.970
I want to make some sort of a chase timer that we use to make bat follow the player for a couple of

17:33.970 --> 17:37.960
seconds, and only after that it's going to fly to the last player's position.

17:37.960 --> 17:40.360
So it's going to look like it's chasing the player.

17:40.360 --> 17:42.100
It's going to be really nice I think.

17:42.100 --> 17:44.500
So let's go over here.

17:44.500 --> 17:45.880
Let's make.

17:46.720 --> 17:48.190
Sterilized field.

17:48.190 --> 17:51.760
Private float chase duration.

17:51.760 --> 17:54.460
I'm going to make it equals to one second by default.

17:54.460 --> 17:56.920
And I need private float.

17:56.920 --> 17:59.050
Chase timer.

17:59.560 --> 18:00.430
Very good.

18:00.430 --> 18:02.740
Now let's go to the update.

18:03.930 --> 18:06.120
Let's do a chase timer.

18:06.390 --> 18:08.700
Minus equals time on delta time.

18:08.730 --> 18:12.150
Okay, then we want to go.

18:14.320 --> 18:15.340
Over here.

18:15.340 --> 18:19.840
And we want to set chase timer equals to chase duration.

18:20.350 --> 18:21.430
Okay.

18:21.760 --> 18:23.200
And then.

18:24.960 --> 18:28.650
Over here inside of the movement, we're going to do something simple.

18:28.650 --> 18:30.060
We're going to update.

18:30.860 --> 18:35.990
Destination according to the player's position, while chase timer is bigger than zero.

18:35.990 --> 18:36.710
So I'm going to do.

18:36.740 --> 18:47.870
If chase timer is bigger than zero, then destination is equals to uh, target transform position.

18:47.870 --> 18:50.210
And let's just be sure this target.

18:51.720 --> 18:53.460
Is not equal to null.

18:54.130 --> 18:56.470
Okay, I want to try this.

18:56.470 --> 18:59.350
I just got this idea and I think it's going to be really cool.

19:00.090 --> 19:04.290
Now let's go back to bed and let's try this on.

19:06.610 --> 19:12.160
So I'm going to, uh, change move speed to maybe eight and let me see this.

19:12.660 --> 19:17.430
So it's flying towards the player, and then at some point it stops chasing the player and it's just

19:17.430 --> 19:19.800
flying to the last position, as you can see.

19:20.070 --> 19:23.700
Let me try to get closer so it's more noticeable.

19:24.810 --> 19:26.970
Yeah, I think it's good.

19:28.810 --> 19:30.040
Makes it better.

19:30.040 --> 19:34.690
Maybe we could make it a bit faster by the time it's just trying to attack the player.

19:34.720 --> 19:36.610
That could be very cool as well.

19:36.610 --> 19:37.390
What is it?

19:42.330 --> 19:43.140
Cancel.

19:45.080 --> 19:47.060
And let's go to enemy bet.

19:51.240 --> 19:54.030
Now we need a variable for default speed.

19:54.030 --> 19:57.600
So I'm going to do private float default speed.

19:58.270 --> 20:00.790
And I'm going to do serialize field.

20:02.280 --> 20:03.360
Scalise field.

20:03.360 --> 20:04.530
Private float.

20:04.710 --> 20:06.300
Attack speed.

20:06.510 --> 20:10.470
Okay, uh, let's go to awake and let's do.

20:11.310 --> 20:14.490
Default speed equals to move speed.

20:15.240 --> 20:15.660
Okay.

20:15.660 --> 20:16.680
Very good.

20:17.100 --> 20:18.870
And we know how this works.

20:18.870 --> 20:20.520
So I'm going to make this as private.

20:20.520 --> 20:22.020
We don't need to see it anymore.

20:24.120 --> 20:25.890
Then, uh.

20:27.600 --> 20:30.150
Over here, we're going to do else.

20:30.270 --> 20:33.180
Uh, move speed equals to attack speed.

20:33.970 --> 20:35.110
Like that.

20:35.110 --> 20:42.190
And then when we, uh, resetting everything over here, I'm going to do move speed equals to default

20:42.190 --> 20:44.170
speed like that.

20:44.410 --> 20:44.830
Okay.

20:44.830 --> 20:46.900
This like lots of confusing code.

20:46.900 --> 20:47.710
Maybe.

20:47.710 --> 20:49.270
Maybe I need to clean this up.

20:49.270 --> 20:49.840
As of now.

20:49.840 --> 20:50.710
This is good.

20:50.920 --> 20:52.510
Uh, let's go and try this.

20:54.860 --> 20:56.210
There is a tag speed.

20:56.210 --> 21:02.180
So I'm going to make move speed as seven and attack speed as 12.

21:02.180 --> 21:03.680
And let me see this.

21:16.320 --> 21:20.340
So it flies faster when it tries to attack me, right?

21:31.110 --> 21:32.490
I think I like it.

21:32.490 --> 21:34.890
We can increase change duration.

21:37.530 --> 21:41.220
To something like 1.5 and I'm going to keep it at that.

21:41.250 --> 21:44.400
Now lastly, I need to be sure I can kill this.

21:44.400 --> 21:46.740
So I'm going to give it move speed of um.

21:47.970 --> 21:51.030
Seven over here and attack speed will be one.

21:51.030 --> 21:54.840
So it flies flow and I have better chance to kill it while we testing this.

21:55.110 --> 21:57.420
Now let's go and do colliders.

21:57.420 --> 21:59.910
We just want to change animation to fly.

22:02.600 --> 22:03.320
Like that.

22:03.320 --> 22:04.010
And let's see.

22:04.040 --> 22:04.970
Collider.

22:06.590 --> 22:09.050
This is the collider for this bed.

22:09.320 --> 22:10.580
Like that.

22:14.920 --> 22:16.150
And this looks good to me.

22:16.150 --> 22:17.860
Let's take the image trigger.

22:18.160 --> 22:21.070
Let's move it here and let's do.

22:23.300 --> 22:24.740
Something like that.

22:26.680 --> 22:30.640
And lastly, this one has a kinematic rigid body.

22:32.050 --> 22:32.890
Over here.

22:32.890 --> 22:35.050
We want to change it to dynamic.

22:35.620 --> 22:36.910
When we kill it.

22:36.910 --> 22:38.500
So I'm going to go back.

22:39.870 --> 22:41.340
The enemy script.

22:41.880 --> 22:45.030
We're going to find die method over here.

22:45.030 --> 22:48.600
And we're going to do something very simple if is kinematic.

22:51.010 --> 22:55.720
RB is kinematic, then RB is kinematic false.

22:56.260 --> 23:00.520
Okay, let me go ahead and try to kill it and be done with this video.

23:05.010 --> 23:05.490
Few.

23:08.280 --> 23:09.870
It could fall faster.

23:09.870 --> 23:12.000
And also, we need to stop the movement.

23:12.570 --> 23:13.020
Um.

23:14.530 --> 23:16.420
So I'm going to go to Enemy Bet.

23:16.420 --> 23:20.740
I'm going to override die method override die.

23:20.860 --> 23:24.130
And we're going to do can move equals false.

23:24.130 --> 23:26.680
Don't we do it on like in here.

23:27.930 --> 23:28.680
We do not.

23:28.680 --> 23:29.070
Okay.

23:29.070 --> 23:29.820
It's fine.

23:30.270 --> 23:33.990
Now let's stop the movement here so it will not try to fly back.

23:35.450 --> 23:37.340
And I think.

23:38.220 --> 23:40.080
The gravity scale should be okay.

23:40.080 --> 23:41.730
Let me check other enemies.

23:43.070 --> 23:44.120
One one.

23:44.120 --> 23:48.590
Everybody, like most of the enemies, have an, uh, gravity scale of one.

23:50.290 --> 23:51.940
So it should be good.

23:52.270 --> 23:53.590
Let me try again.

24:02.950 --> 24:05.170
How am I so bad at this game?

24:07.840 --> 24:09.520
Okay, Hugh.

24:10.290 --> 24:11.130
Yeah.

24:11.160 --> 24:11.970
Cute.

24:11.970 --> 24:12.840
Love it.

24:13.500 --> 24:17.550
Uh, now, let's make move speed over here.

24:19.600 --> 24:19.720
Uh.

24:19.720 --> 24:21.010
Let's try.

24:22.320 --> 24:24.540
Let's try nine and attack speed.

24:24.540 --> 24:27.900
Let's try 12, which is duration 1.5.

24:27.900 --> 24:29.160
So I'm going to keep it as it is.

24:29.160 --> 24:33.420
I'm going to go to a prefab folder with enemies and make it as a prefab.

24:33.420 --> 24:34.920
And we're good.

24:35.310 --> 24:37.020
Let's go to the next video.
