WEBVTT

00:00.050 --> 00:00.500
Hello guys.

00:00.500 --> 00:01.490
Welcome to the video.

00:01.490 --> 00:05.360
In this one I want to show you how to make a ghost enemy.

00:05.360 --> 00:07.520
This ghost will appear from a random point.

00:07.520 --> 00:11.510
It will fly towards the player and then it will disappear after some time.

00:12.110 --> 00:13.250
That's what we need to do.

00:13.250 --> 00:18.380
Before we do that though, let's do something to improve logic of flying enemies.

00:18.830 --> 00:20.900
So first of all, maybe I'll take the bet.

00:20.900 --> 00:25.490
I'll place it over here and I'll decrease aggro radius to something like.

00:26.220 --> 00:26.910
That.

00:26.910 --> 00:27.570
All right.

00:27.600 --> 00:28.890
Now let's go to layers.

00:28.890 --> 00:30.210
Let's add.

00:31.120 --> 00:34.090
Enemy fly or something like that.

00:34.090 --> 00:34.330
Yeah.

00:34.330 --> 00:42.010
So basically flying enemy maybe let's do flying enemy and then let's go to Edit project settings.

00:42.100 --> 00:48.880
We need to disable collision between flying enemy and other enemies and also between flying enemy and

00:48.880 --> 00:49.780
ground.

00:49.780 --> 00:54.970
That's what we need to do because enemy not supposed to interfere with platforms, even though we're

00:54.970 --> 00:57.400
using movement with a vector to move towards.

00:57.400 --> 00:58.630
And it does not bother us.

00:58.630 --> 01:02.920
Now, just in case I want to do things right now, let's go to prefab.

01:02.920 --> 01:09.460
Let's take players prefab and let's change what is enemy to enemy and flying enemy.

01:09.460 --> 01:12.490
We just need to hold shift and click flying enemy as well.

01:12.490 --> 01:13.330
Like that.

01:15.240 --> 01:19.170
An enemy bet itself can be flying enemy now.

01:19.740 --> 01:21.180
Now this object only.

01:21.180 --> 01:23.310
And then I'm going to apply overrides.

01:23.310 --> 01:24.180
Very well.

01:24.180 --> 01:26.160
Now we want to make a ghost enemy.

01:26.160 --> 01:27.930
Let's go and check the graphics.

01:29.370 --> 01:30.990
Sorry enemy.

01:31.530 --> 01:32.340
Ghost.

01:32.340 --> 01:33.360
Here it is.

01:33.360 --> 01:35.640
Idle it.

01:35.760 --> 01:38.460
Uh, ghost particles appear and disappear.

01:38.460 --> 01:39.780
So this is what we want to do.

01:40.350 --> 01:41.430
Uh, how can we do this?

01:41.430 --> 01:42.900
First of all, we need to take them all.

01:42.900 --> 01:44.820
Make pixel per unit 16.

01:46.950 --> 01:49.860
Then let's do prefab unpack completely for the bed.

01:49.890 --> 01:51.300
I think we're not going to use it now.

01:51.960 --> 01:55.020
It will only make things harder to test.

01:55.020 --> 02:00.390
So I'm going to do unpack completely and let's change it to enemy ghost.

02:02.070 --> 02:03.030
All right.

02:03.030 --> 02:09.180
Now, uh, let's take maybe idle sprite, give it to sprite renderer over here.

02:09.240 --> 02:11.250
Here we have a ghost now.

02:11.370 --> 02:17.550
And let's go to animations and make animator controller enemies.

02:17.550 --> 02:20.700
We're going to make a folder ghost.

02:20.910 --> 02:25.200
Let's go inside and let's make animation.

02:25.200 --> 02:27.420
Animator controller enemy.

02:27.420 --> 02:28.800
Ghost make.

02:30.340 --> 02:32.740
I'm going to sign it over here.

02:32.830 --> 02:35.380
And then we need to create a bunch of animations.

02:36.830 --> 02:37.700
Enemies.

02:37.700 --> 02:38.210
Sorry.

02:38.210 --> 02:42.560
We need to create, uh, enemies.

02:42.590 --> 02:43.610
Ghost.

02:43.610 --> 02:45.140
We're going to have enemy.

02:45.170 --> 02:46.100
Ghost.

02:46.190 --> 02:47.450
Uh, move!

02:47.450 --> 02:50.180
There's an idle animation, but it will be used for moving.

02:50.180 --> 02:52.820
So let's just do move here.

02:53.210 --> 02:57.290
And then we're going to go to graphics enemies.

02:58.010 --> 02:59.060
Uh, ghost.

02:59.060 --> 03:02.180
Let's take this idle animations and drag them here.

03:02.330 --> 03:04.160
Sample rate 20.

03:04.160 --> 03:05.660
So this is how it looks.

03:07.740 --> 03:12.090
I think it can be used for flying as well, so I it's fine, I guess.

03:12.090 --> 03:13.710
I like it this way.

03:13.710 --> 03:15.510
Now let's make another clip.

03:16.330 --> 03:18.730
Enemy ghost hit.

03:20.040 --> 03:21.360
Going to take this hit.

03:21.600 --> 03:22.770
Drag it here.

03:22.770 --> 03:24.330
Sample rate 20.

03:25.050 --> 03:28.350
Then we want to go and make.

03:29.360 --> 03:33.740
Enemy ghost appear and disappear.

03:33.770 --> 03:36.650
So maybe let's call it that appear.

03:37.190 --> 03:39.170
I'm going to take animations of appearing.

03:40.430 --> 03:41.720
Sample rate 20.

03:41.750 --> 03:42.890
Let's see it.

03:43.510 --> 03:45.940
Yeah, fast enough, but it's okay.

03:45.940 --> 03:47.620
And we also need new clip.

03:48.900 --> 03:51.990
Enemy ghost disappear.

03:54.390 --> 03:58.170
And we're going to take these sprites over here and drag them here.

03:58.170 --> 04:00.390
Sample rate 20.

04:00.720 --> 04:04.650
Regarding the particles, I'm not sure I want to use them.

04:06.450 --> 04:07.770
Just some particles.

04:07.770 --> 04:08.910
Well.

04:09.910 --> 04:16.120
We could basically take the dust effect we have and just reduce the emission to make the amount of particles

04:16.120 --> 04:17.590
less than we have on a dust.

04:18.070 --> 04:19.900
But I think I'm not going to use it.

04:19.900 --> 04:20.620
It's okay.

04:20.650 --> 04:25.960
Now let's go and, uh, think how it's going to work.

04:25.960 --> 04:27.610
We need a script on this.

04:28.380 --> 04:33.540
So I'm going to go ahead to scripts folder enemies and we're going to make.

04:34.990 --> 04:36.580
Enemy ghost.

04:38.290 --> 04:39.460
Okay.

04:46.190 --> 04:48.080
Let's put it on the script.

04:48.080 --> 04:50.750
I mean, on the game object, enemy ghost.

04:50.750 --> 04:52.850
And let's go inside of the script.

04:53.210 --> 04:58.580
We're going to inherit from the enemy as well as always.

04:58.580 --> 05:00.560
Then we want to make a header.

05:00.560 --> 05:04.760
Let's do, uh, let's do ghost details.

05:05.180 --> 05:08.330
And then I just want to explain how it's going to work.

05:08.330 --> 05:12.830
So we're going to have an idle timer and we're going to have an active timer.

05:12.830 --> 05:14.360
While ghost is idle.

05:14.360 --> 05:15.470
It's going to be invisible.

05:15.470 --> 05:16.940
And it will not chase the player.

05:16.940 --> 05:18.590
It's going to be basically not there.

05:18.590 --> 05:24.230
And then when ghost is active, it's going to appear from the random side of the player, and it's going

05:24.230 --> 05:29.240
to move towards the player and it's going to feel threatening, like he's always chasing you and you

05:29.240 --> 05:31.310
don't know from which side he's going to jump.

05:31.310 --> 05:37.220
Before we do entire functionality, let's just make him appear and disappear with a cooldown.

05:37.220 --> 05:43.910
Okay, so I'm going to do serialize field, private float active duration, and I'm going to make Private

05:43.910 --> 05:46.010
float Active timer.

05:46.010 --> 05:48.500
Then let's override update.

05:48.500 --> 05:52.100
We're going to do active timer minus equals time dot delta time.

05:52.100 --> 05:55.400
Oh and also we need private bool is active.

05:55.400 --> 06:00.500
Then we need two methods private void start chase.

06:00.500 --> 06:04.580
And we need private void and Chase.

06:04.580 --> 06:07.100
In the update we're going to do a simple check.

06:07.100 --> 06:13.160
If is active is false and idle timer is less than zero.

06:13.160 --> 06:17.690
It means we've been idle for long enough and it's time to chase the player.

06:17.690 --> 06:20.570
And we're going to do start chase.

06:20.840 --> 06:24.800
Then if we are chasing the enemy, I mean the player.

06:24.800 --> 06:30.590
So else if is active and active, timer is below zero.

06:30.590 --> 06:32.990
So time to chase is over.

06:32.990 --> 06:36.110
We're going to do end chase just like that.

06:37.320 --> 06:40.290
Inside of these methods, we need to do something super simple.

06:41.230 --> 06:48.640
When we start the chase, we just say that active timer is equals to active duration and is active.

06:48.670 --> 06:49.210
True.

06:49.210 --> 06:55.510
And when we end the chase we're going to do idle timer equals to idle duration.

06:55.510 --> 06:57.310
So it's going to be idle for a while.

06:57.310 --> 07:00.130
And we're going to do is active pulse.

07:00.130 --> 07:03.550
And maybe let's rename this to is chasing.

07:03.940 --> 07:05.260
Yeah a bit better.

07:05.840 --> 07:07.250
More logic in this.

07:07.760 --> 07:13.250
And I think this could be good enough, but I want to trigger animation as well.

07:13.250 --> 07:16.610
So before I forgot this let's do anim triggers.

07:16.610 --> 07:19.820
We're going to do anim set trigger.

07:20.460 --> 07:21.510
Of, uh.

07:21.510 --> 07:23.640
When we start Chase, we appear.

07:23.640 --> 07:29.850
So I'm going to do appear over here with a small letter, and then we're going to need disappear.

07:29.880 --> 07:31.170
Disappear.

07:31.470 --> 07:32.250
Okay.

07:32.430 --> 07:35.070
Uh, let's go back to unity now.

07:36.910 --> 07:37.360
Over here.

07:37.360 --> 07:42.100
We're going to select animator of the ghost, and I do not see any animations.

07:42.100 --> 07:44.260
So I will have to restart unity.

07:44.260 --> 07:45.220
Give me a sec.

07:45.250 --> 07:45.760
Okay.

07:45.760 --> 07:47.470
Here are the animations.

07:47.470 --> 07:50.020
Let's move any state over here.

07:50.050 --> 07:51.610
Ghost heat over here.

07:51.610 --> 07:53.020
Move over here.

07:53.020 --> 07:54.580
Appear and disappear.

07:54.610 --> 07:55.300
Okay.

07:56.180 --> 07:58.460
So we need two parameters.

07:58.460 --> 07:59.480
Three parameters.

07:59.480 --> 08:01.040
One of them going to be heat.

08:01.160 --> 08:04.130
This is for, uh, making enemy die.

08:04.130 --> 08:10.130
So I'm going to use condition heat duration zero can transit to self and check.

08:12.080 --> 08:13.790
Then in the animator.

08:14.960 --> 08:19.790
It doesn't really matter how we do it here, because it's going to be pretty much the same anyways.

08:19.970 --> 08:22.940
And let's go and copy the name over here.

08:22.940 --> 08:25.940
So I will not make any mistakes because I'm like that.

08:26.780 --> 08:27.260
Um.

08:28.950 --> 08:29.910
Disappear.

08:29.910 --> 08:30.990
And then.

08:32.250 --> 08:32.400
Ah!

08:32.400 --> 08:34.710
We're here, I'm here.

08:36.230 --> 08:36.950
Trigger.

08:37.830 --> 08:38.460
Appear.

08:38.460 --> 08:43.710
Okay, so while we move, we can do transition to ghost appear.

08:45.870 --> 08:48.360
Let's do appear.

08:48.360 --> 08:50.490
Transition duration zero.

08:51.340 --> 08:52.450
Exit time and check.

08:52.450 --> 09:00.850
Then we're going to transfer back to move with the exit time of one, transition duration zero, and

09:00.850 --> 09:03.430
we need to do same for disappear.

09:03.430 --> 09:08.140
So we're going to transfer here with the trigger of disappear.

09:09.300 --> 09:16.350
Transition duration zero as exit time, uncheck and transition back will go with the exit time of one.

09:16.710 --> 09:18.630
Transition duration zero.

09:19.050 --> 09:22.980
So basically it will play animation once and then it will go back to Ghost Move.

09:23.640 --> 09:25.200
Now let's go back to Scene view.

09:25.230 --> 09:31.050
Let's take the anime ghost and we want to assign ground check over here.

09:31.050 --> 09:32.460
What is player.

09:32.460 --> 09:33.300
Sorry.

09:36.760 --> 09:38.260
What is ground?

09:40.160 --> 09:42.800
What is ground and that should be it.

09:42.800 --> 09:44.540
Let me check colliders.

09:46.030 --> 09:47.740
This is Box Collider.

09:49.280 --> 09:51.350
Barely visible, but it's fine.

09:51.860 --> 09:52.250
And then.

09:52.250 --> 09:53.420
Damage trigger.

09:54.920 --> 09:56.210
Like that.

09:57.230 --> 09:58.820
Should be okay.

10:00.570 --> 10:03.840
All right, now let's go over here.

10:03.840 --> 10:07.320
Let's make active duration equals to 1.5.

10:08.240 --> 10:13.790
Idle duration is 1.5, and if I'm not wrong, it's supposed to just appear and disappear.

10:13.820 --> 10:14.300
Now.

10:15.870 --> 10:16.650
Appeared.

10:16.650 --> 10:17.970
Disappeared.

10:18.000 --> 10:19.050
Appeared.

10:19.530 --> 10:20.520
Disappeared.

10:20.550 --> 10:22.620
Very nice, very nice.

10:22.620 --> 10:24.510
Now let's make something else.

10:24.510 --> 10:28.950
Let's make this ghost transparent every time it disappears.

10:28.950 --> 10:30.690
There are many different ways to do that.

10:30.690 --> 10:33.990
I think I'm going to do this with the help of animation events.

10:34.200 --> 10:35.670
And let's go somewhere below.

10:35.670 --> 10:37.980
And let's make private void.

10:37.980 --> 10:40.440
Make invisible.

10:40.440 --> 10:41.280
This will do.

10:41.400 --> 10:46.140
SR we have sprite renderer, I'm sure of that.

10:46.650 --> 10:48.030
Let me check enemy.

10:50.880 --> 10:51.990
This one is private.

10:52.020 --> 10:54.600
Okay, I'm going to make it as protected.

10:55.390 --> 10:57.790
All right, let's go back.

10:59.230 --> 11:01.060
And we're going to do this.

11:01.060 --> 11:02.650
Our color.

11:03.160 --> 11:04.120
This is invisible.

11:04.120 --> 11:06.910
So I'm going to do color dot clear.

11:07.390 --> 11:11.530
And then we're going to do private void make visible.

11:11.530 --> 11:15.550
It's going to be SR color equals to color dot white.

11:16.120 --> 11:17.080
Very nice.

11:17.080 --> 11:18.250
Let's save this.

11:18.250 --> 11:24.070
And let's go and try this again with the disappearing, uh logic.

11:25.140 --> 11:28.170
You're going to go to enemy ghost appear.

11:28.470 --> 11:33.300
And every time we appear over here, we want to make ghost visible.

11:33.300 --> 11:37.140
So enemy ghost methods make visible.

11:37.530 --> 11:40.200
Then we want to go to enemy ghost disappear.

11:40.200 --> 11:43.650
And we want to make it transparent every time we disappear.

11:43.650 --> 11:46.080
Maybe one frame after that.

11:46.080 --> 11:47.160
Over here.

11:47.580 --> 11:50.100
Enemy ghost methods make invisible.

11:50.550 --> 11:51.990
Now this is supposed to work.

11:51.990 --> 11:53.430
I just want to see this.

11:53.430 --> 11:57.420
Also, I'm a bit worried that we will not see all of the frames of animation.

11:57.420 --> 12:00.240
So I'm going to take these frames, move them like so.

12:00.240 --> 12:03.210
So first frame will make it visible.

12:03.210 --> 12:08.700
Then it will play the animation, but it will be so fast we will not notice an extra frame.

12:08.700 --> 12:10.170
Let's go to play mode.

12:13.040 --> 12:13.910
Visible.

12:13.910 --> 12:15.200
Invisible.

12:15.200 --> 12:16.400
Visible.

12:16.640 --> 12:20.240
Invisible magic, right, I love it.

12:22.540 --> 12:28.210
Now we also need to disable colliders so it will not damage enemy and it will not be killed.

12:28.210 --> 12:34.330
And we have logic with the colliders over here, but since we need it for the second time, I guess

12:34.330 --> 12:36.280
we can extract it as method.

12:36.790 --> 12:41.920
I'm going to do extract method enable colliders.

12:41.920 --> 12:46.330
We're going to pass a boolean over here, same as we did before.

12:46.330 --> 12:47.140
Enable.

12:48.310 --> 12:53.620
Then we're going to pass enable over here and over here we're going to say false.

12:53.620 --> 12:56.050
So it's just the same as it was before.

12:57.130 --> 13:01.630
Now we can go to enemy ghost and we can expand these methods.

13:02.400 --> 13:08.160
And when we make it clear and invisible, we're going to do enable colliders.

13:08.190 --> 13:10.560
Oh, I'm sorry, that method is private.

13:10.860 --> 13:12.150
Let's go and fix it.

13:12.180 --> 13:14.700
Let's make it as protected.

13:15.300 --> 13:16.650
Okay, I'm going to save it.

13:16.740 --> 13:18.090
Go back here.

13:20.200 --> 13:23.170
Enable colliders polls.

13:23.200 --> 13:26.710
Then we want to extend this method over here.

13:27.250 --> 13:28.930
Enable colliders.

13:28.930 --> 13:29.740
True.

13:30.410 --> 13:30.860
Okay.

13:30.860 --> 13:31.670
Very good.

13:31.670 --> 13:34.910
Now, this is half of the job that we need to do.

13:35.270 --> 13:41.870
Uh, once we start the chase of the player, we want to place ghost at some random position around the

13:41.870 --> 13:42.740
player.

13:42.890 --> 13:50.630
I know from a testing and from experience that we should not have a very big position on the Y, probably

13:50.630 --> 13:53.000
something like from 0 to 10, a random one.

13:53.000 --> 13:56.990
And for the X should be at least five, maybe on the x.

13:56.990 --> 13:59.930
So let's go ahead and make some variables.

14:02.140 --> 14:06.370
I'm going to make a space and then I'll do serialize field, private float.

14:07.760 --> 14:13.490
X mean distance, then I want to have serialized field private float y.

14:13.520 --> 14:16.130
Min distance and serialized field.

14:16.220 --> 14:17.780
Private float y.

14:17.780 --> 14:19.130
Max distance.

14:19.130 --> 14:20.630
That's all what we need.

14:22.080 --> 14:25.980
Now we're going to go back to start Chase method.

14:27.200 --> 14:28.280
And over here.

14:28.280 --> 14:33.320
First of all, we want to check if there are players on the map, because if there are no players on

14:33.320 --> 14:37.310
the map, then we're supposed to end the chase immediately.

14:37.310 --> 14:39.530
We're not supposed to even start the chase.

14:39.530 --> 14:40.910
So this is what we're going to do.

14:40.940 --> 14:44.570
We're going to make list of player right here.

14:44.960 --> 14:45.590
Sorry.

14:47.610 --> 14:50.640
Player list and we need to go here.

14:50.640 --> 14:57.240
Click alt enter using system generics then equals to player manager dot instance get player list.

14:57.240 --> 15:00.210
So this will make a list inside of this method.

15:00.210 --> 15:03.960
And it will fill it up and make it equals to players list on the player manager.

15:03.960 --> 15:10.050
Then we're going to check if player list dot count is less or equals to zero means we cannot do any

15:10.050 --> 15:12.060
change because there is no one to chase.

15:12.060 --> 15:16.380
So we're going to end Chase immediately and we're going to return from this method.

15:16.380 --> 15:18.960
And if that's not the case, then we can move on.

15:18.960 --> 15:22.950
And first of all, we would like to find a target that we want to chase.

15:24.030 --> 15:29.370
So let's go ahead and make a variable private transform.

15:30.110 --> 15:32.030
Target like that.

15:32.450 --> 15:35.150
Then we can go back to start Chase method.

15:36.470 --> 15:41.390
And we want and we want to make target equals to random player from the list.

15:41.510 --> 15:44.540
So I'm going to do int random.

15:46.000 --> 15:52.990
Index equals to random range from zero to player list dot count, and then target equals to player list

15:52.990 --> 15:56.350
with a random index dot transform.

15:56.710 --> 15:57.190
Nice.

15:57.190 --> 16:00.340
So now we find the target is going to be random player from the list.

16:00.340 --> 16:05.680
After that we want to calculate the position that we will have for this ghost.

16:05.680 --> 16:15.880
So I'm going to do so I'm going to do float y position equals to random range from mean y distance from

16:15.880 --> 16:17.860
y minimum distance to y.

16:17.860 --> 16:20.590
Maximum distance is going to be random y.

16:20.590 --> 16:26.950
And for the x we don't want to have position because we have only one value minimum x distance.

16:26.950 --> 16:29.140
But we want to have the offset.

16:29.140 --> 16:31.210
Uh the offset will be very simple.

16:31.210 --> 16:33.250
It's going to be either 1 or -1.

16:33.250 --> 16:38.500
And because of that, uh, ghost will appear sometimes on the left, sometimes on the right.

16:38.500 --> 16:39.940
That's all what we want to do.

16:39.940 --> 16:43.360
So let's do y x offset equals to.

16:43.360 --> 16:46.870
And over here I want to do a quick if statement.

16:47.230 --> 16:51.520
Uh, before I do that let me show you how it looks without quick if statement.

16:51.520 --> 16:53.020
So we do fly.

16:53.020 --> 16:55.570
So we do float x offset equals to one.

16:55.570 --> 17:04.960
Then if random range between 0 and 100 is less than 50 then it's 50% chance to turn it into x offset

17:04.960 --> 17:06.370
equals to minus one.

17:06.370 --> 17:08.170
So this is how you can write it.

17:08.170 --> 17:11.830
Or you can write it this way equals two.

17:11.860 --> 17:14.200
We're going to ask random range.

17:14.950 --> 17:18.160
From 0 to 100 is less than 50.

17:19.130 --> 17:21.050
If yes, do minus one.

17:21.050 --> 17:22.910
If no, do one.

17:23.000 --> 17:25.250
And it's a bit cleaner and prettier.

17:25.610 --> 17:28.910
So we've got the offset and the Y position.

17:29.720 --> 17:36.770
Then we can take transform position and make it equals to target dot position, which is a players position

17:36.770 --> 17:44.930
plus new vector three with x minimum distance multiplied by x offset and y position.

17:44.930 --> 17:45.830
Just like that.

17:45.830 --> 17:49.250
And this will make ghost appear from different sides of the player.

17:49.250 --> 17:50.960
Let's go and see this.

17:50.960 --> 17:54.260
And then we only need to make it move and it's going to be it.

17:54.260 --> 17:55.610
Let's go and try.

17:56.270 --> 17:58.670
I forgot to set values over here.

17:58.670 --> 18:02.720
Let's do x minimum distance five y minimum distance.

18:02.720 --> 18:07.520
Let's try random from maybe -7 to 7 okay.

18:07.520 --> 18:11.180
So they're going to be a range on the Y.

18:11.180 --> 18:12.590
Let's go and see this.

18:15.550 --> 18:21.640
It disappeared because there is no player I'm going to respawn and then it appears from random size

18:21.640 --> 18:22.570
of the player.

18:24.040 --> 18:24.280
Wait.

18:24.280 --> 18:25.330
I don't see it.

18:25.360 --> 18:26.650
Oh, there it is.

18:28.800 --> 18:29.700
Very nice rate.

18:31.810 --> 18:32.380
Yeah.

18:33.210 --> 18:34.740
Really nice, I love it.

18:34.770 --> 18:40.110
Now let's use it and let's make him move towards the player and also face the player.

18:40.110 --> 18:41.730
You're going to go back to script.

18:42.340 --> 18:43.270
Um.

18:44.660 --> 18:48.950
I guess when we start the chase, we can do handle flip.

18:50.070 --> 18:50.640
Wait about what?

18:50.640 --> 18:54.150
If a player jumps over the ghost or runs below it?

18:54.390 --> 18:57.360
Then we need to do it in the movement method.

18:57.360 --> 18:58.110
Yes.

18:58.500 --> 19:00.180
Uh, let's go and make.

19:02.370 --> 19:03.360
Private void.

19:04.560 --> 19:06.510
Handle movement.

19:07.480 --> 19:10.990
If can move equals to false, then we return same as before.

19:10.990 --> 19:17.950
And then we do transform position equals to vector to move towards from transform position to the target

19:17.950 --> 19:22.840
dot position with a move speed multiplied by time dot delta time.

19:23.920 --> 19:24.940
Just like that.

19:25.150 --> 19:28.270
Then we want to handle movement over here.

19:28.270 --> 19:31.570
And probably we should stop movement when we kill the ghost.

19:31.570 --> 19:33.580
So let's go and override.

19:35.280 --> 19:38.910
Uh die method and do can move equals to false.

19:39.480 --> 19:45.060
I don't want to stop movement in the base method, because it is funny when mushroom is running and

19:45.060 --> 19:50.130
you kick him and he is flying to the direction that he was running, I love it, so I'm going to keep

19:50.130 --> 19:50.550
it.

19:52.000 --> 19:55.060
But other than that, I think we're good.

19:55.060 --> 19:57.820
We don't need to do anything else here.

19:58.390 --> 19:59.980
Uh, let me go and see this.

20:01.700 --> 20:03.020
There is a ghost.

20:04.420 --> 20:05.830
Ghost enemy.

20:08.220 --> 20:11.250
I'm going to give him off speed of maybe four.

20:11.760 --> 20:12.930
Just when I feel.

20:13.790 --> 20:15.140
How dangerous he is.

20:16.850 --> 20:19.790
And I respond, oh no, he's not facing me.

20:21.910 --> 20:23.680
Oh, did I kill it?

20:24.280 --> 20:24.970
You.

20:26.440 --> 20:27.310
This is so funny.

20:27.310 --> 20:31.090
Okay, I've seen him jump into a new location after I killed him.

20:31.090 --> 20:33.070
That is not what we supposed to have.

20:33.070 --> 20:35.830
So first of all, let's go to animations enemies.

20:35.830 --> 20:36.640
Ghost.

20:36.640 --> 20:42.340
Let's take this animation appear, disappear and hit disable loop time.

20:43.690 --> 20:45.280
Then let's go to the script.

20:46.110 --> 20:49.650
We're gonna go here and do something very simple.

20:49.650 --> 20:52.080
If is dead, then return.

20:52.080 --> 20:53.400
This is supposed to help.

20:53.580 --> 20:56.070
He will not get new position.

20:56.660 --> 21:05.060
And yeah, if you want, you can turn this into a boolean for sort of clearance, but I think it's fine.

21:05.420 --> 21:08.090
And was there something else I forgot.

21:09.770 --> 21:11.510
I forgot what was.

21:13.610 --> 21:14.600
Is it okay?

21:15.290 --> 21:16.580
I don't remember.

21:18.390 --> 21:18.900
Just.

21:20.920 --> 21:21.610
Our flipping.

21:21.610 --> 21:22.330
Yes!

21:22.330 --> 21:23.320
Oh, my.

21:23.350 --> 21:24.520
Can you imagine?

21:24.940 --> 21:29.800
Over here we're going to do a handle flip according to the target position.

21:31.150 --> 21:31.990
Dot x.

21:31.990 --> 21:32.560
Yeah.

21:32.560 --> 21:33.580
This is good.

21:33.940 --> 21:35.470
All right.

21:35.680 --> 21:37.840
Thank you so much guys.

21:37.840 --> 21:44.710
This was amazing and pretty fun.

21:45.700 --> 21:48.460
Yeah I'll see you in the next video I guess.

21:50.950 --> 21:51.820
By.
