WEBVTT

00:00.170 --> 00:00.560
Hello guys.

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

00:01.490 --> 00:04.040
In this one we're going to make another enemy.

00:04.040 --> 00:06.290
It's going to be enemy Reddish.

00:06.290 --> 00:10.340
This one is quite tricky but at the same time a very simple one.

00:10.850 --> 00:15.260
If we open the graphics we can see that this one has an idle.

00:15.260 --> 00:21.470
If we open this spreadsheet, we can see it has sort of a flying animation, because this one has this

00:21.470 --> 00:24.770
little leaves over here and it's spinning like a propeller.

00:26.260 --> 00:27.040
Yeah.

00:27.040 --> 00:29.080
And then there is this idol.

00:29.910 --> 00:34.650
Over here without leaves, and in this one he is supposed to walk on the ground.

00:34.650 --> 00:40.650
Also, it has running animation over here, so I think it's going to be a pretty fun anime to make.

00:40.650 --> 00:46.230
The lodge are going to be a very simple, uh, it's going to fly in the air somewhere here.

00:46.230 --> 00:49.710
If you jump on the head of this enemy, he's going to fall to the ground.

00:49.710 --> 00:56.220
He's going to walk, do a circle, come back to the position he had, and then fly up to the position

00:56.220 --> 00:57.000
he had.

00:57.000 --> 00:58.350
That's what I want to do.

00:58.740 --> 01:06.450
Uh, let's delete extra bees and let's do prefab and park completely.

01:07.490 --> 01:08.870
Is going to be reddish.

01:09.920 --> 01:14.030
Now we're going to take Idle Sprite from here and drag it to Sprite Renderer.

01:14.590 --> 01:15.550
Like that.

01:16.950 --> 01:19.350
And let's make pixel per unit.

01:20.480 --> 01:21.770
16.

01:21.980 --> 01:24.170
And let's remove enemy B.

01:24.830 --> 01:32.300
Let's go to scripts folder enemies and let's make a script enemy reddish.

01:34.330 --> 01:36.160
Going to put it on the game object.

01:36.640 --> 01:36.970
A.

01:38.500 --> 01:39.040
What's up?

01:41.710 --> 01:42.550
Like that.

01:43.090 --> 01:43.960
Very nice.

01:43.960 --> 01:44.920
Love it.

01:45.310 --> 01:50.110
Uh, we need animator, so let's go to Asset Animations.

01:50.110 --> 01:51.070
Enemy.

01:51.670 --> 01:54.250
And I think I can copy animator.

01:54.250 --> 01:55.690
Controller of the mushroom.

01:55.690 --> 01:56.920
Let me copy this.

01:57.190 --> 02:00.700
Go to enemies, make a folder for radish.

02:02.500 --> 02:08.680
Go inside of this folder, paste the scene, and let's rename this to Enemy Radish.

02:08.710 --> 02:12.970
I'm doing this because this one has a bunch of a setup that we can use on enemy radish.

02:13.000 --> 02:14.620
Let's drag it here.

02:15.350 --> 02:19.040
Let's go to animator and let's just see it, okay?

02:19.040 --> 02:21.500
This is almost everything that we need.

02:22.160 --> 02:25.790
Uh, we're going to just transfer to heat from any state.

02:27.350 --> 02:29.300
With a heat trigger.

02:30.540 --> 02:32.010
Can transit to self uncheck.

02:32.010 --> 02:34.200
Let's delete this transition over here.

02:34.710 --> 02:39.930
And let's go ahead and create animations for this because this is using the animations from mushroom.

02:40.320 --> 02:43.590
Let's go to animations enemy radish.

02:44.760 --> 02:45.120
Uh.

02:45.720 --> 02:46.200
I'm sorry.

02:46.200 --> 02:50.010
I need to be sure I did not mess up the mushroom itself.

02:56.720 --> 02:57.530
This one is here.

02:57.530 --> 02:58.580
Should be fine.

02:59.650 --> 03:00.400
Okay.

03:01.570 --> 03:03.160
And let's do create new clip.

03:04.350 --> 03:05.310
Enemy.

03:05.820 --> 03:06.420
Uh, sorry.

03:06.420 --> 03:08.400
Make sure you select enemy reddish.

03:10.660 --> 03:12.880
And let's do create new clip.

03:13.630 --> 03:15.430
Enemy reddish.

03:17.070 --> 03:17.730
Idol.

03:19.060 --> 03:20.590
I'm going to go to graphics.

03:21.360 --> 03:22.230
Enemies.

03:23.380 --> 03:24.310
Uh, reddish.

03:25.290 --> 03:27.000
The second idol we're going to use now.

03:27.660 --> 03:28.320
Sample rate.

03:28.350 --> 03:29.010
20.

03:31.420 --> 03:32.620
Let's double check it.

03:32.830 --> 03:33.100
Yeah.

03:33.100 --> 03:34.990
This is the one where he stands.

03:35.110 --> 03:38.230
Okay, let's go and create new clip.

03:39.030 --> 03:40.500
Enemy radish.

03:40.500 --> 03:41.430
Move!

03:44.170 --> 03:45.910
I'm going to take the run sprites.

03:46.480 --> 03:47.260
Take them.

03:47.260 --> 03:48.280
Drag them here.

03:48.280 --> 03:49.750
Separate 20.

03:52.520 --> 03:54.200
Then let's make one more.

03:56.000 --> 03:58.850
Enemy radish lie idle.

03:59.420 --> 04:00.230
And over here.

04:00.230 --> 04:02.690
We need to take idle from the first one.

04:04.350 --> 04:05.910
Going to drag it here.

04:05.910 --> 04:07.500
Sample rate 20.

04:08.630 --> 04:10.910
And we need enemy reddish heat.

04:11.330 --> 04:13.610
Enemy reddish heat.

04:14.450 --> 04:15.890
December 8th 20.

04:16.430 --> 04:19.970
And we're going to take these sprites over here and drag them here.

04:20.000 --> 04:20.780
Okay.

04:20.780 --> 04:24.650
Now, before I forget, let's go to Asset Animations.

04:24.650 --> 04:25.640
Enemies.

04:26.240 --> 04:26.930
Reddish.

04:26.930 --> 04:29.420
Let's take the hit and uncheck loop time.

04:29.540 --> 04:32.240
Now we need to set up these things over here.

04:32.870 --> 04:38.330
Uh, we can take enemy hit here and just drag this enemy reddish heat to this field.

04:38.480 --> 04:44.990
And now we do need this animation over here because it is in this, um, uh, animation state.

04:46.060 --> 04:47.560
Right there is the motion.

04:48.040 --> 04:51.100
Uh, also, we can remove idol and move.

04:51.100 --> 04:55.030
We can go inside of this blend tree and assign them over here.

04:55.600 --> 04:56.680
This is idol.

04:56.680 --> 04:57.550
Sorry.

04:57.550 --> 04:58.960
Enemies.

04:59.650 --> 05:00.820
How did this happen?

05:00.820 --> 05:01.750
Reddish.

05:02.300 --> 05:02.900
Yeah.

05:03.610 --> 05:04.030
Um.

05:05.370 --> 05:06.270
Idol.

05:07.810 --> 05:08.650
Move.

05:09.510 --> 05:10.230
Move.

05:11.360 --> 05:11.840
Okay.

05:11.840 --> 05:13.070
This is good.

05:13.340 --> 05:15.530
Now let me go back and double check the heat.

05:15.740 --> 05:17.060
Yeah, this is fine.

05:17.060 --> 05:18.680
And now we have this fly.

05:18.710 --> 05:20.630
We're going to make another boolean.

05:21.430 --> 05:21.970
Play.

05:23.440 --> 05:24.340
Uh, is flying.

05:24.340 --> 05:24.940
Is better.

05:24.940 --> 05:25.840
Is flying.

05:26.880 --> 05:31.650
And we're going to just transfer to this is flying if it's a true.

05:33.740 --> 05:36.680
And check exit time transition duration zero.

05:36.680 --> 05:41.540
And then we're going to transfer to fly animation if is flying is true.

05:43.990 --> 05:45.730
Then we're going to transfer back.

05:47.130 --> 05:50.880
If is flying is false.

05:51.240 --> 05:53.430
Zero and check exit time.

05:54.740 --> 05:58.790
Nice animator is ready and let's go inside of the script.

06:01.110 --> 06:03.420
Let's inherit from the enemy.

06:05.170 --> 06:09.760
And then I guess we can just take the logic from the mushroom.

06:12.110 --> 06:14.450
Let's take this logic from here.

06:14.780 --> 06:17.300
Go to enemy radish, paste it in.

06:17.390 --> 06:19.310
I'm going to do close all but this.

06:19.310 --> 06:22.340
And now it's supposed to work as it is.

06:22.370 --> 06:30.650
And we only need to add functionality where enemy flies up or falls down, walks and then flies up.

06:31.160 --> 06:32.300
That's what we need to do.

06:32.300 --> 06:35.810
Before we do that though, let's go and make sure it is working right now.

06:40.970 --> 06:44.270
Going to go to seen, uh, ground check.

06:45.810 --> 06:47.640
Hear what this player.

06:50.270 --> 06:51.380
Ground.

06:53.580 --> 06:55.920
Now let's fix the collider.

06:57.250 --> 06:58.570
Should be like that.

07:01.220 --> 07:01.910
Yeah.

07:06.940 --> 07:11.770
And for the damage trigger, let's decrease it from the Y.

07:13.980 --> 07:14.490
Okay.

07:14.490 --> 07:15.420
This is good.

07:16.720 --> 07:17.620
Uh, ground check.

07:17.620 --> 07:18.640
It's fine.

07:18.640 --> 07:20.140
Everything is fine to me.

07:20.890 --> 07:22.030
Yeah, everything looks fine.

07:22.030 --> 07:23.050
Let's do player detection.

07:23.050 --> 07:24.430
Zero, because we don't need it.

07:24.430 --> 07:25.540
And we'll check.

07:25.540 --> 07:27.070
Distance should be wider.

07:27.430 --> 07:28.540
Something like that.

07:30.840 --> 07:32.040
Now I'm going to go to play mode.

07:32.040 --> 07:34.530
It's supposed to fall and walk left and right.

07:36.830 --> 07:37.670
Oh, wow.

07:38.090 --> 07:39.320
How do you do that?

07:40.160 --> 07:40.940
Why?

07:41.120 --> 07:43.460
Okay, I know, I'm sorry.

07:44.330 --> 07:44.840
Over here.

07:44.840 --> 07:46.580
We need to change to dynamic.

07:53.880 --> 07:54.870
Oh my God!

07:55.290 --> 07:56.640
What is happening to you?

07:56.640 --> 07:57.780
Supposed to fold.

08:05.690 --> 08:06.560
Not like that.

08:06.560 --> 08:08.270
Oh, I know, I'm so sorry.

08:08.360 --> 08:12.380
Like an enemy should be changed to an enemy.

08:12.800 --> 08:14.450
No, this object only.

08:14.450 --> 08:16.760
Okay, let me try again.

08:21.010 --> 08:21.820
Yeah.

08:21.850 --> 08:22.900
All right.

08:23.260 --> 08:24.100
This is good.

08:24.130 --> 08:25.240
He walks.

08:29.730 --> 08:31.290
This is not good, man.

08:31.680 --> 08:33.090
This is not.

08:33.740 --> 08:34.670
Great.

08:42.790 --> 08:48.520
Now let's increase ground check distance to point three and we'll check distance to, uh.

08:49.110 --> 08:49.800
Where is he?

08:55.100 --> 08:57.290
And let's do 1.3.

08:57.290 --> 09:00.650
I'll just take the ground check and move it below like that.

09:02.210 --> 09:04.760
Okay, let's make sure it is working.

09:04.760 --> 09:06.020
We just need to be sure.

09:06.020 --> 09:08.720
I'm going to give it gravity scale of two so it falls faster.

09:08.720 --> 09:10.130
And let's go and see this.

09:11.730 --> 09:12.210
Boom.

09:16.790 --> 09:17.750
Okay.

09:17.750 --> 09:19.100
This is good.

09:19.130 --> 09:20.000
I like it.

09:24.400 --> 09:28.630
Now let's go back to the script and let's adjust it a little bit.

09:30.580 --> 09:33.100
So we're going to need a header.

09:35.270 --> 09:37.100
Reddish details.

09:37.100 --> 09:42.200
And as of now I want to make a public bull is flying just so we know it is working.

09:42.590 --> 09:44.330
Then we need to override.

09:45.100 --> 09:45.970
Override.

09:47.210 --> 09:48.950
Uh, die method.

09:49.310 --> 09:56.450
And over here we're going to do if is flying equals to false, then it's going to do is flying equals

09:56.450 --> 09:57.290
to true.

09:57.380 --> 09:59.690
Else we're just going to kill it as it was before.

10:04.930 --> 10:08.080
All right, then we need to override animator.

10:08.080 --> 10:09.730
Override animator.

10:09.940 --> 10:14.680
And over here we're going to do anim set bool of ease flying.

10:14.710 --> 10:16.330
To ease flying.

10:16.720 --> 10:17.500
Perfect.

10:19.090 --> 10:21.310
Now, uh, from the start.

10:21.310 --> 10:22.300
Let's overwrite.

10:22.300 --> 10:23.020
Start.

10:24.220 --> 10:29.680
We're going to do is Flynn equals to true because it's supposed to start in the air, and I want it

10:29.680 --> 10:31.600
to fly up in a certain way.

10:31.600 --> 10:33.640
I don't want to use vector to move towards.

10:33.640 --> 10:35.830
I want to use rigid bodies velocity.

10:35.830 --> 10:37.120
So we're gonna.

10:38.110 --> 10:40.270
And, uh, serialize field.

10:40.270 --> 10:41.410
Private float.

10:42.190 --> 10:43.090
Why?

10:44.140 --> 10:46.660
Maybe fly force something like that.

10:46.660 --> 10:52.720
And we want to have sterilized field private float, min fly distance.

10:52.720 --> 10:59.170
And this reddish will fly above the ground with a certain like with a certain distance.

10:59.170 --> 11:04.630
And if distance is higher than it should be, then it will stop pushing itself up.

11:04.630 --> 11:09.730
Because of that, it's going to look like it's always trying to fly up, but it cannot.

11:09.730 --> 11:10.570
Uh, you'll see it.

11:10.570 --> 11:11.560
It's really nice.

11:12.950 --> 11:17.240
Then over here we want to handle movement only if we are grounded.

11:17.780 --> 11:20.090
So maybe like that.

11:25.210 --> 11:26.470
And I think.

11:30.570 --> 11:31.800
I think we can do this.

11:31.800 --> 11:34.590
If is flying, then.

11:35.660 --> 11:37.850
And they'll line.

11:38.630 --> 11:40.010
Let's do method.

11:43.180 --> 11:44.470
Are we going to adjust it later on?

11:44.470 --> 11:45.430
As of now, this is good.

11:45.430 --> 11:53.800
We just need to make the fly in logic, and I want to have some sort of a check how far from distance

11:53.800 --> 11:55.930
the radius is.

11:56.080 --> 11:57.580
For that we cannot use boolean.

11:57.580 --> 11:58.810
We need to do something else.

11:58.810 --> 12:06.460
We want to make um private raycast hit to the ground below.

12:07.550 --> 12:08.870
Uh, detected.

12:10.290 --> 12:12.930
And we need to override handle collision.

12:17.160 --> 12:17.730
I'm going to do.

12:17.730 --> 12:18.390
Override.

12:18.420 --> 12:20.550
Handle collision inside.

12:20.550 --> 12:21.810
I want to do ground below.

12:21.810 --> 12:23.850
Detected equals to physics 2D.

12:25.720 --> 12:26.800
Recast.

12:27.910 --> 12:28.570
Transform.

12:28.570 --> 12:31.630
Position vector two dot down.

12:32.200 --> 12:32.920
Um.

12:33.130 --> 12:34.300
We need.

12:34.850 --> 12:38.480
I guess we need a maximum float value here, so float.

12:39.990 --> 12:42.060
Load max value.

12:43.150 --> 12:44.560
And what is ground.

12:45.760 --> 12:51.190
Okay, so this will always make a raycast that is checking where is the ground below.

12:51.190 --> 12:52.900
And it's going to use infinite distance.

12:52.900 --> 12:55.600
So it's going to just detect ground anyway.

12:56.050 --> 12:59.140
Then we're going to go back to the start method.

12:59.470 --> 13:06.670
And in the start we want to make minimum fly distance equals to the current distance we have at the

13:06.670 --> 13:08.860
moment of uh like start of the game.

13:08.860 --> 13:09.580
That's why we're doing this.

13:09.610 --> 13:10.240
In the start.

13:10.240 --> 13:12.220
We sort of saving the default value.

13:12.220 --> 13:16.990
Thanks to that, you can just place radish on the level and you will not have to worry about changing

13:16.990 --> 13:17.800
variables.

13:17.800 --> 13:20.260
It's going to save itself on its own.

13:20.260 --> 13:24.520
And you can just place the radish and it's going to fly approximately on that point.

13:25.170 --> 13:30.360
So we're going to do mean fly distance equals to ground below.

13:30.750 --> 13:32.280
Dot distance.

13:32.520 --> 13:33.360
Just like that.

13:33.360 --> 13:37.050
Now let's go to the fly I mean handle flying.

13:37.050 --> 13:39.330
And over here we're going to do something simple.

13:39.330 --> 13:48.480
If ground below dot distance is less than mean fly distance then we're going to do RB velocity equals

13:48.480 --> 13:49.800
to new vector two.

13:50.820 --> 13:52.200
Uh, zero on the X.

13:52.200 --> 13:53.610
Lifeforce on the Y.

13:54.060 --> 14:02.160
Thanks to this now, reddish supposed to push itself up when it goes down just a bit.

14:02.370 --> 14:04.230
And let's go ahead and try this.

14:05.310 --> 14:09.510
Let's go back to unity and we're going to go to the game window.

14:13.010 --> 14:17.570
I think we need to add fly force, but I don't know how much so.

14:18.560 --> 14:19.640
Let me try.

14:19.640 --> 14:20.930
Fly force.

14:21.080 --> 14:21.920
Maybe.

14:22.900 --> 14:23.410
Three.

14:24.740 --> 14:25.070
Okay.

14:25.070 --> 14:26.720
And I'll place it over here.

14:26.720 --> 14:28.430
So this where it's supposed to be?

14:28.430 --> 14:30.740
Let's say we don't have this piece of ground.

14:30.950 --> 14:32.330
I mean, the platform.

14:32.810 --> 14:33.590
General.

14:33.680 --> 14:36.350
Where is the tile 3D tile palette?

14:39.110 --> 14:44.660
Let's say this one is not there and I need to use reddish to get to this point over here.

14:44.660 --> 14:46.580
So it's supposed to be like that, right?

14:46.580 --> 14:47.570
That's the jump.

14:48.110 --> 14:49.520
Let's go and see it now.

14:53.210 --> 14:53.930
Oh, no.

14:54.380 --> 14:55.340
It fell.

14:58.310 --> 14:59.840
Let's make it true by default.

14:59.840 --> 15:01.640
Supposed to be true anyways.

15:04.000 --> 15:07.450
Um, we're not saving minimum flight distance for some reason.

15:10.370 --> 15:11.630
That's the problem.

15:11.630 --> 15:13.130
Let's go and check it.

15:36.460 --> 15:37.240
All right.

15:37.450 --> 15:45.070
Um, maybe it's not updated by the time it's supposed to be updated here, but I guess it is not updated

15:45.070 --> 15:45.940
at the start.

15:45.940 --> 15:47.920
And that's why it makes it zero.

15:48.160 --> 15:49.630
Let's do it like that.

15:51.710 --> 15:52.280
All right.

15:52.280 --> 15:55.640
We sort of just doing recast once at the start.

15:55.640 --> 15:58.340
I'm going to save it and I'm going to try again.

16:01.410 --> 16:02.580
Please work.

16:02.580 --> 16:04.050
Supposed to work.

16:06.400 --> 16:07.180
All right.

16:07.180 --> 16:09.730
Now it does what we need it to do, right?

16:09.730 --> 16:11.260
It stays above the ground.

16:11.260 --> 16:14.950
And also it's trying to fly up once it's falling down.

16:14.950 --> 16:21.220
So it looks like it's really floaty, like it's trying hard I like it I only want to change something

16:21.220 --> 16:21.820
here.

16:21.820 --> 16:27.610
I want to slow down the animation of a fly, maybe to 15 on the sample rate.

16:27.610 --> 16:32.320
So it looks a bit slower and kind of like lazy here.

16:32.320 --> 16:36.850
And maybe let's reduce gravity scale back to one so it's not so heavy.

16:36.850 --> 16:42.430
And for the fly force, let's try to keep it at three or maybe 3.5.

16:45.480 --> 16:47.730
Okay, now I'm going to see this.

16:50.310 --> 16:53.130
Oh, yeah, I like it a little bit more now.

16:53.130 --> 16:56.520
It's kind of like trying to get up and it cannot.

16:56.520 --> 16:58.080
I think it's good enough.

16:58.080 --> 17:00.570
I like it if you want, you can play with variables.

17:00.570 --> 17:03.450
Just if you make it heavier, it's going to pull harder.

17:03.450 --> 17:06.660
If you make life force higher, it's going to fly up more.

17:06.660 --> 17:07.800
That's what it's going to do.

17:07.800 --> 17:11.070
Now let me just try to check the functionality of it.

17:11.070 --> 17:15.030
Like it's kind of like a falling platform, but life.

17:16.110 --> 17:16.680
You.

17:18.090 --> 17:20.940
So it was not supposed to die.

17:20.940 --> 17:22.170
And.

17:22.810 --> 17:24.220
That's what we need to fix.

17:24.220 --> 17:25.240
Let's go back.

17:27.280 --> 17:31.270
Another method if is flying through.

17:31.870 --> 17:33.580
Then is flying false.

17:33.580 --> 17:37.000
This is how it was supposed to be.

17:37.480 --> 17:38.320
Okay.

17:39.550 --> 17:41.440
Now, if I'm not mistaken.

17:41.800 --> 17:43.120
Uh, wait a second.

17:43.120 --> 17:43.720
Yeah.

17:43.720 --> 17:45.340
It's supposed to fall down.

17:45.340 --> 17:47.140
Then it's supposed to walk left and right.

17:47.140 --> 17:50.110
And after that, we only need to add a little bit of a logic.

17:50.110 --> 17:54.310
We want it to fly back to the position it had once.

17:54.310 --> 17:56.380
It's walked for a bit.

17:57.290 --> 17:57.860
Okay.

17:57.860 --> 17:58.910
Yeah, this is good.

17:58.940 --> 18:01.430
Now, if I jump on, the head is gonna die.

18:01.430 --> 18:04.550
And now we need to make it fly up when it goes back.

18:04.910 --> 18:07.040
So let's go to enemy reddish.

18:11.730 --> 18:20.550
Um, I'm going to use some sort of a timer, private float, walk timer, and let's do serialize field.

18:23.670 --> 18:26.280
Private float walk duration.

18:26.280 --> 18:26.580
Okay.

18:26.580 --> 18:30.180
I'm going to make it equals to two by default just so we can see how it works.

18:30.180 --> 18:37.590
Also, now that we know mean fly distance is updated, we can make it as private without showing it.

18:37.590 --> 18:38.700
And.

18:39.470 --> 18:43.730
I guess this boolean can be private as well because now we know it is working.

18:43.760 --> 18:44.510
All right.

18:45.620 --> 18:46.010
Now.

18:46.010 --> 18:48.380
What do we need when we.

18:50.400 --> 18:51.660
Kick it for the first time.

18:51.660 --> 18:55.530
We're going to do walk timer equals to walk duration.

18:55.890 --> 18:56.880
Just like that.

18:58.210 --> 18:59.260
Just like that.

18:59.950 --> 19:08.950
Then we're going to go to the update and we're going to do else let's open curly brackets and move it

19:08.950 --> 19:10.450
here like that.

19:10.450 --> 19:11.440
Maybe we can move.

19:11.440 --> 19:12.550
This is grounded.

19:12.550 --> 19:16.660
Check inside of a method so it does not bother us here.

19:16.660 --> 19:17.740
And what do you think.

19:17.740 --> 19:20.230
So it's a bit cleaner I'm going to do.

19:20.230 --> 19:24.070
If is grounded false then return.

19:24.070 --> 19:25.900
And same on the movement.

19:26.880 --> 19:29.250
If is grounded.

19:29.760 --> 19:31.770
False return.

19:31.770 --> 19:38.730
Now, thanks to this, we can go back to update and just remove this condition over here.

19:39.000 --> 19:40.020
Very cool.

19:42.410 --> 19:47.840
Inside of this, we're going to do, um, maybe actually, we can do just above.

19:49.430 --> 19:53.450
Uh, walk timer minus equals time delta time.

19:53.450 --> 19:59.240
And then if walk timer is below zero, then.

20:00.250 --> 20:01.300
Is flying.

20:02.110 --> 20:09.370
Equals to true, but this will just make it fly up and we don't want it to just fly up.

20:09.370 --> 20:13.540
We want it to fly approximately on the same position it had.

20:13.870 --> 20:17.230
Um, if we want to do that, we want to save the X position.

20:17.230 --> 20:18.520
So let's go.

20:18.520 --> 20:19.210
And.

20:20.140 --> 20:22.360
Maybe do a private float.

20:23.440 --> 20:26.140
X original position.

20:26.380 --> 20:32.140
And at the start we're going to do x original position equals to transform.

20:32.440 --> 20:33.910
Position dot x.

20:34.390 --> 20:35.200
Nice.

20:35.290 --> 20:37.420
Now we want to go.

20:39.440 --> 20:42.500
To this method and we want to make its Flynn true.

20:42.500 --> 20:49.250
Not only if walk timer is below zero, but also if difference between current text position and original

20:49.250 --> 20:51.140
x position is not very big.

20:51.320 --> 20:54.230
We can do that just by simply do end.

20:55.180 --> 20:56.230
Math.

20:56.410 --> 20:58.120
F absolute.

20:58.120 --> 20:58.420
Maybe.

20:58.420 --> 21:00.100
Let's make a variable for this.

21:00.700 --> 21:01.870
Let's do float.

21:03.530 --> 21:15.710
X difference equals to uh math f dot absolute between transform.position.x and x minus x original position.

21:16.430 --> 21:23.360
And then if X difference is less than maybe 0.15 or 0.1 F.

21:23.480 --> 21:30.200
So difference between position that we have right now an original position is less than 0.1 F means

21:30.200 --> 21:35.360
we are approximately at the same place we were, we at the same place where we supposed to be and we

21:35.360 --> 21:37.160
can make is flying true.

21:37.400 --> 21:38.510
That's the thing.

21:38.870 --> 21:40.520
Uh, let's go and try this.

21:41.690 --> 21:43.370
Let's go back to unity.

21:52.920 --> 21:57.390
I'm just going to hit the play button and it's going to fly there.

21:57.390 --> 22:02.490
I like it, and I'm going to just try to jump on the head of the radish.

22:03.180 --> 22:04.020
Hey, boy.

22:05.110 --> 22:05.620
You.

22:06.130 --> 22:07.270
It's going to fly down.

22:07.270 --> 22:07.990
Walk.

22:09.820 --> 22:11.860
And then it flies up back.

22:12.460 --> 22:14.680
All right, this is it.

22:15.160 --> 22:16.420
This is what we need.

22:16.600 --> 22:20.380
It's going to walk a little bit until the duration is over.

22:20.380 --> 22:22.930
And then it's like, hey, I'm flying up.

22:23.560 --> 22:24.880
Nice.

22:24.880 --> 22:26.260
Very nice.

22:28.450 --> 22:31.450
Yeah, maybe I would like it to fall faster.

22:32.490 --> 22:34.650
Other than that, I think it's good.

22:35.040 --> 22:35.520
Oh.

22:36.480 --> 22:39.750
Or no, we not supposed to have it like that.

22:39.990 --> 22:43.530
Let me try to see if I can kill it while it works.

22:43.530 --> 22:45.120
And then I'm going to check that bug.

22:49.230 --> 22:52.110
It's walking and I'm killing it.

22:53.810 --> 22:55.970
Ah, this is weird.

22:58.180 --> 23:02.800
Let's take the damage trigger and let's reduce it on the Y.

23:02.830 --> 23:04.120
Something like that.

23:04.800 --> 23:05.640
Okay.

23:06.990 --> 23:11.490
On the X can be something like this I think should be okay.

23:13.810 --> 23:15.220
Also, I've got an idea.

23:15.220 --> 23:17.980
I want to make it heavier just when we jump on the head.

23:17.980 --> 23:21.850
So I'm going to do, uh, gravity scale.

23:22.270 --> 23:25.630
RB gravity scale equals to maybe three.

23:25.630 --> 23:29.680
And then when we flying back over here.

23:30.360 --> 23:35.850
I'm going to do gravity scale or be gravity scale equals to one.

23:36.360 --> 23:37.260
Alrighty.

23:38.400 --> 23:40.080
Let me try this again.

23:42.330 --> 23:43.620
I did not like that glitch.

23:43.620 --> 23:47.340
Also, I feel like this animation does not have a flash when we kick it.

23:47.610 --> 23:48.660
Enemy.

23:49.620 --> 23:50.940
Uh, where is it?

23:53.730 --> 23:54.540
Reddish.

23:56.920 --> 24:00.220
It has white sprites, but I feel like I didn't see it.

24:02.850 --> 24:03.990
It becomes white.

24:06.980 --> 24:08.480
Why do I feel like we can't?

24:08.480 --> 24:10.220
A little bit of the animation.

24:14.310 --> 24:15.150
Animator.

24:15.150 --> 24:16.140
Enemy hit.

24:17.620 --> 24:18.880
Our transition duration.

24:18.880 --> 24:20.110
Let's make it zero.

24:20.560 --> 24:21.220
Okay.

24:21.930 --> 24:22.830
Supposed to be good.

24:22.830 --> 24:24.870
Now let's go and try.

24:33.970 --> 24:35.890
You falls down.

24:36.430 --> 24:37.870
Walks around.

24:39.130 --> 24:40.810
And Pew!

24:40.960 --> 24:41.920
Pew!

24:43.780 --> 24:46.150
I love it, boy, this is so pretty.

24:47.470 --> 24:48.400
All right.

24:48.400 --> 24:55.510
Um, last thing I would like to do is sort of a Polish thing, but I really want to do it when we jump

24:55.510 --> 24:57.580
on the head of the enemy for the first time.

24:57.670 --> 25:02.140
It does not flash white, and it looks like just nothing happened.

25:02.140 --> 25:07.000
So I wanted to make it white when we're hitting it for the first time while he's flying.

25:07.000 --> 25:12.430
And we don't have animations for that, so we'll have to code it, but it's not that difficult to do.

25:13.210 --> 25:13.630
We're going to do.

25:13.630 --> 25:16.030
Private eye enumerator.

25:17.050 --> 25:20.080
Oh no, wait, it's not going to be that easy to do either.

25:20.620 --> 25:21.130
Uh.

25:23.660 --> 25:24.440
Okay.

25:24.440 --> 25:26.120
This is what we have to do.

25:28.850 --> 25:29.360
Wait.

25:29.360 --> 25:30.830
I don't remember how it works.

25:30.830 --> 25:32.630
I need to open an RPG course.

25:41.070 --> 25:42.510
All right, here it is.

25:42.840 --> 25:44.220
I just need to check.

25:46.650 --> 25:48.960
The flash material.

25:48.960 --> 25:51.270
How does it work over here?

25:51.360 --> 25:53.610
It just texts shader.

25:54.210 --> 25:54.450
Okay.

25:54.450 --> 25:55.200
And it's empty.

25:55.230 --> 25:55.500
Okay.

25:55.500 --> 25:56.670
This is what we need to do.

25:56.760 --> 25:58.680
And let's go back to our project.

26:00.600 --> 26:02.070
We want to go to asset.

26:04.680 --> 26:05.970
Materials.

26:07.050 --> 26:12.450
I'm going to make material, uh, flesh material.

26:13.940 --> 26:17.120
Okay, we're gonna change it to, um.

26:23.650 --> 26:25.750
GUI text shader.

26:26.080 --> 26:26.980
Just like that.

26:27.880 --> 26:31.960
Now if you go to Sprite renderer and place this material.

26:31.960 --> 26:33.220
Now wait a second.

26:33.220 --> 26:34.570
Not sprite renderer.

26:34.570 --> 26:35.950
Yes, sprite renderer.

26:35.950 --> 26:39.520
If you place this material over here, the.

26:40.290 --> 26:45.240
Red is going to become white completely, then you can revert these changes back to default one.

26:45.240 --> 26:47.520
And we can do this in the script.

26:47.670 --> 26:50.280
Let's go back to the enemy radio script.

26:52.270 --> 26:54.220
I'm going to make a variable.

26:55.070 --> 26:56.210
Let's do space.

26:56.210 --> 26:57.740
Serialized field.

26:57.740 --> 26:59.600
Private material.

26:59.630 --> 27:01.190
Flash material.

27:01.580 --> 27:03.680
Then we want to go down.

27:03.680 --> 27:05.000
Sorry, that was too quick.

27:05.000 --> 27:05.960
Flash material.

27:05.960 --> 27:07.040
That is what we need.

27:08.320 --> 27:11.110
Oh, and also, we need private material.

27:11.200 --> 27:12.250
Uh, regional.

27:13.760 --> 27:14.810
Material.

27:15.500 --> 27:22.220
Then we're going to go to start and do, um, original material equals to SR dot material.

27:23.920 --> 27:24.670
All right.

27:25.550 --> 27:30.050
Now we're going to go down and we're going to make a coroutine.

27:30.200 --> 27:31.940
I enumerator.

27:32.680 --> 27:35.350
Lash fix coroutine.

27:36.010 --> 27:38.050
Let's do right.

27:38.260 --> 27:44.200
Then let's do something like, uh, SR material equals to flash material.

27:44.200 --> 27:46.780
Then we're going to do yield return new.

27:46.780 --> 27:55.690
Let's do wait four seconds of maybe 0.1 F and then SR material equals to original material just like

27:55.690 --> 27:56.230
that.

27:56.560 --> 27:58.210
And then when we kick in it.

27:59.300 --> 27:59.900
We're going to do.

27:59.900 --> 28:00.320
Start.

28:00.320 --> 28:03.470
Coroutine of a flash, a fixed coroutine.

28:04.020 --> 28:04.980
All right.

28:04.980 --> 28:07.710
A quick, neat trick on how to flash.

28:08.770 --> 28:09.700
The sprite.

28:12.650 --> 28:20.120
Now we need to go to this field, assign it with a flash material, and we can go to play mode and see

28:20.120 --> 28:21.260
how it works.

28:22.500 --> 28:24.300
And we're going to be done with this video.

28:30.280 --> 28:30.640
You.

28:30.640 --> 28:35.410
Now it becomes white a little bit when you hit it for the first time, same as it flashes white when

28:35.410 --> 28:37.450
you kick it to kill it.

28:38.390 --> 28:39.320
Yes.

28:39.320 --> 28:40.010
Good.

28:40.010 --> 28:41.030
Good job guys.

28:41.030 --> 28:42.650
I'll see you in the next video.

28:43.530 --> 28:43.950
I'll wait.

28:43.950 --> 28:45.480
Let's make it as a prefab.

28:46.180 --> 28:48.850
We're going to go to enemies and make enemy reddish.

28:49.030 --> 28:51.370
Alrighty, I'll see you in the next one.
