WEBVTT

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

00:00.530 --> 00:01.400
Welcome to the video.

00:01.400 --> 00:03.950
And this one we're going to make Last Enemy in this section.

00:03.950 --> 00:05.180
Going to be a very fun one.

00:05.180 --> 00:09.140
Let me show you an example in my prototype project real quick.

00:09.140 --> 00:10.430
So there is a snail.

00:10.430 --> 00:13.820
You can jump on the top of the snail to bounce it off the shell.

00:13.820 --> 00:16.430
Then you can jump on the shell to make it move like that.

00:16.850 --> 00:19.250
And if you stand on the way, it will damage you.

00:19.900 --> 00:22.570
If you jump on the top of the shell, it's going to fly away.

00:23.520 --> 00:28.140
Simple as that is just like the mushroom enemy, but with a little bit of extension.

00:28.140 --> 00:30.390
So that's what I'm going to show you in this video.

00:30.390 --> 00:32.070
First, let's set up the game object.

00:32.070 --> 00:33.780
This one's going to be pretty easy to do.

00:34.110 --> 00:36.540
We need a mushroom I'm going to duplicate it.

00:36.540 --> 00:38.070
Place it over here.

00:40.440 --> 00:45.870
Then let's do prefab unpack completely and let's name it as Enemy Snail.

00:49.600 --> 00:55.810
Then we're going to remove the script and we're going to go to Graphics Enemies snail.

00:55.810 --> 00:58.570
Make sure you have pixel per unit 16.

00:59.020 --> 01:01.690
Then you go ahead to Sprite Renderer.

01:02.360 --> 01:04.820
And take idle sprite from here.

01:05.030 --> 01:06.260
Okay, cool.

01:06.350 --> 01:08.090
Now we need animator.

01:08.600 --> 01:10.880
Let's go here and make a folder.

01:17.160 --> 01:18.150
Uh, snail.

01:18.920 --> 01:21.080
Then we need the animator controller.

01:22.640 --> 01:25.100
Enemy snail AC.

01:26.880 --> 01:29.730
Gonna put it over here in the animator.

01:30.120 --> 01:32.040
Now we need a bunch of animations.

01:32.640 --> 01:35.130
We need quite a few, like 5 or 6.

01:35.130 --> 01:36.180
So let's begin.

01:36.180 --> 01:37.500
We're going to click create.

01:37.500 --> 01:40.500
First we need enemy snail idle.

01:42.380 --> 01:43.850
Going to go to graphics.

01:45.630 --> 01:46.380
Enemy.

01:46.830 --> 01:50.820
Uh, snail, there is the idle sprites going to drag them here.

01:50.820 --> 01:52.470
Sample rate 20.

01:55.460 --> 01:57.110
Then we need new clip.

01:57.850 --> 01:58.450
Enemy.

01:58.450 --> 01:59.740
Snail.

01:59.740 --> 02:00.730
Move.

02:02.180 --> 02:03.470
Going to take this one.

02:05.900 --> 02:07.400
Sample rate 20.

02:07.610 --> 02:10.250
Now we need one more for the heat.

02:10.250 --> 02:15.290
So enemy snail heat gonna take hit sprite.

02:15.290 --> 02:16.220
Drag them here.

02:16.220 --> 02:17.450
Sample array 20.

02:17.810 --> 02:23.030
Now this is going to be the simple animation for the just walk in functionality.

02:23.540 --> 02:27.920
Then once we jump on the top of the snail, we're going to switch to another set of animations where

02:27.920 --> 02:30.380
we have no body of the snail but only shell.

02:30.380 --> 02:33.170
So let's make animations for the shell.

02:33.170 --> 02:36.980
We're going to make enemy snail shell idle.

02:39.830 --> 02:41.240
These are the sprites.

02:42.560 --> 02:43.910
Then we need new clip.

02:44.620 --> 02:48.580
Enemy snail shell heat.

02:48.610 --> 02:51.430
This is what we're going to use for the jumping on the top of the snail.

02:51.430 --> 02:52.930
Like to display the damage.

02:55.270 --> 02:56.710
And also an enemy.

02:56.710 --> 03:00.640
I mean, when snail bounces off the wall, we need another animation here.

03:00.640 --> 03:04.900
It's going to be enemy snail shell wall hit.

03:06.440 --> 03:07.490
This is the one.

03:08.980 --> 03:09.220
Uh.

03:09.220 --> 03:09.820
We'll hit.

03:09.820 --> 03:10.510
Let's take it.

03:10.510 --> 03:11.650
Put it here.

03:11.650 --> 03:12.940
Sample rate 20.

03:15.710 --> 03:17.060
And this is good for now.

03:17.090 --> 03:20.000
Now let's go ahead to assets.

03:20.210 --> 03:21.500
Animations.

03:21.500 --> 03:22.700
Enemies.

03:23.340 --> 03:24.150
Snail.

03:24.150 --> 03:25.320
And we're going to take hit.

03:25.350 --> 03:26.010
Hit.

03:26.010 --> 03:28.500
And we'll hit and uncheck loop time.

03:30.120 --> 03:31.860
Now we need to set up animator.

03:31.860 --> 03:33.390
Going to be not that difficult to do.

03:33.420 --> 03:37.200
Let's select the snail and let's make a new blend tree.

03:37.890 --> 03:39.120
This one going to be.

03:39.980 --> 03:41.480
I'll move.

03:42.140 --> 03:44.600
I need to restart unity because I have this bug.

03:44.630 --> 03:45.590
Give me a second.

03:47.450 --> 03:48.830
All right, I'm back.

03:48.890 --> 03:52.370
Let's select and do idle move.

03:53.020 --> 03:54.760
Then we're going to open this blend tree.

03:54.760 --> 03:57.670
This parameter are going to be x velocity.

03:59.630 --> 04:01.550
We can add motion field.

04:02.300 --> 04:03.470
Three times.

04:03.680 --> 04:05.060
Let's move.

04:05.510 --> 04:07.880
Move idle.

04:08.270 --> 04:10.850
Move and check automate threshold.

04:10.850 --> 04:14.240
And we're going to have minus one zero one.

04:15.610 --> 04:20.380
Okay, now we need to go back and set this as a default one.

04:21.440 --> 04:23.180
Handle and move can be deleted.

04:23.860 --> 04:29.110
Then from the idle move, we can transfer to heat to display the damage.

04:29.740 --> 04:34.390
And after that we're going to transfer to shell idle to show snail without a body.

04:34.390 --> 04:37.090
So we need a trigger heat.

04:38.140 --> 04:43.780
We're going to transfer to enemy snail, hit with a trigger and check exit time.

04:43.780 --> 04:45.400
Transition duration zero.

04:45.970 --> 04:53.830
Then we're going to transfer from hit to shell idle over here to display like a next stage of the snail.

04:54.310 --> 04:56.320
Here we're going to have exit time one.

04:56.830 --> 04:58.840
Transition duration zero.

04:58.870 --> 05:03.790
Now after we jump on the head of the snail for the first time, this is going to be the default state

05:03.790 --> 05:04.660
of the snail.

05:04.660 --> 05:10.060
And we will be able to transfer to a shell hit when we damage it.

05:10.060 --> 05:13.180
And we'll hit when snail bounces off the wall.

05:13.180 --> 05:16.090
So let's make transition here with a hit.

05:18.380 --> 05:22.490
And transition duration should be zero as well as the exit time.

05:22.790 --> 05:26.180
Then transfer back can be with the exit time of one.

05:26.180 --> 05:28.010
Transition duration zero.

05:28.040 --> 05:28.730
Cool.

05:28.730 --> 05:31.370
And for the wall heat, we need another trigger.

05:32.460 --> 05:32.730
Sorry.

05:32.730 --> 05:33.750
We need the trigger.

05:35.090 --> 05:38.990
We'll hit and we're going to make transition here.

05:40.240 --> 05:40.990
With the wall.

05:40.990 --> 05:43.750
Hit exit time zero.

05:43.750 --> 05:45.490
Transition duration zero.

05:46.000 --> 05:49.300
And then transition back with the exit time one.

05:50.760 --> 05:53.670
Okay, let's all what we need on the animator.

05:53.700 --> 05:55.110
Now let's go back.

05:55.840 --> 05:58.990
Let's place the snail over here.

05:58.990 --> 06:00.940
Maybe so it will flip immediately.

06:01.390 --> 06:03.760
Now we need a scripts.

06:03.760 --> 06:08.920
And let's make new script for enemy snail.

06:10.740 --> 06:11.430
Okay.

06:11.430 --> 06:12.330
Okay, okay.

06:14.680 --> 06:18.130
Let's put it on the game object and let's go inside our script.

06:19.340 --> 06:20.120
Over here.

06:20.120 --> 06:22.430
We want to inherit from the enemy.

06:23.400 --> 06:27.540
And we just want to take the script from a mushroom to make sure it's working.

06:27.540 --> 06:31.020
And then we're going to, uh, improve the script, upgrade it.

06:31.020 --> 06:32.610
So let's go to mushroom.

06:33.330 --> 06:35.640
Let's take everything from here.

06:36.810 --> 06:38.730
Just these three methods.

06:38.790 --> 06:40.050
I'm going to copy it.

06:40.050 --> 06:42.990
Go back to snail over here.

06:42.990 --> 06:47.190
And we want to, uh, just make a boolean.

06:47.190 --> 06:48.870
Let's do public.

06:49.260 --> 06:53.160
Public bool has body.

06:53.280 --> 06:55.110
And let's make it true by default.

06:55.230 --> 07:01.470
And this will help us to define what we need to do with the snail when we jump on the head of the like

07:01.470 --> 07:02.700
of the snail itself.

07:02.700 --> 07:03.120
Okay.

07:03.120 --> 07:06.330
So we're going to override the method die.

07:06.330 --> 07:08.130
Let's do override die.

07:08.250 --> 07:11.400
And usually we just call method die when we detect the enemy.

07:11.400 --> 07:13.110
But here we want to do this.

07:13.110 --> 07:16.770
If has body then we want to stop movement.

07:16.770 --> 07:19.440
So can move equals to false.

07:20.330 --> 07:22.910
We want to say the snail is losing its body.

07:22.910 --> 07:25.310
So we're going to do has body equals to false.

07:25.310 --> 07:30.770
And we want to disable the idle time so it can run left and right and bounce off the walls.

07:30.770 --> 07:33.260
So I'm going to do idle duration equals to zero.

07:33.260 --> 07:35.570
And also it would be nice to trigger animation.

07:35.570 --> 07:37.670
So I'm going to do anim set trigger.

07:38.380 --> 07:38.890
Hit.

07:39.800 --> 07:41.210
So this one can happen.

07:41.210 --> 07:45.800
And in another case, if doesn't have anybody, then it's going to die.

07:46.010 --> 07:47.210
Let's do else.

07:49.110 --> 07:49.800
Die.

07:51.460 --> 07:52.540
Just like that.

07:52.540 --> 07:55.570
So this will do a lot of functionality.

07:55.600 --> 08:00.340
We only need to go to handle movement over here and add another check.

08:00.340 --> 08:05.110
If can move equals to false then return also.

08:05.110 --> 08:06.130
Now can move.

08:06.130 --> 08:09.400
Boolean is false by default on all of the enemies.

08:09.400 --> 08:11.260
So let's go to enemy script.

08:13.430 --> 08:17.570
And on the enemy I want to make can move equals to true by default.

08:17.570 --> 08:22.730
Because of that, this will be true for all of the enemies we have, and I think we need to go to the

08:22.730 --> 08:23.780
enemy rhino.

08:24.470 --> 08:28.220
And make it can move poles at the start.

08:29.770 --> 08:31.900
Okay, now let's get back to snail.

08:31.900 --> 08:33.040
It can move.

08:33.040 --> 08:36.430
Once we jump on the head of the snail, it's going to stop.

08:36.640 --> 08:39.730
Oh, by the way, let's do our velocity equals to vector zero.

08:39.730 --> 08:40.690
So it's going to stop.

08:41.660 --> 08:42.380
Yeah.

08:43.220 --> 08:46.070
And then when we jump on the head again, it's going to die.

08:46.100 --> 08:47.720
Now let's go ahead and try that.

08:50.540 --> 08:53.420
And we only need to assign a couple of things here.

08:53.420 --> 08:56.510
So ground check what is player?

08:56.510 --> 08:58.400
What is ground.

08:58.400 --> 09:01.820
We don't need player detection but we need to reset.

09:01.820 --> 09:02.810
Collider.

09:02.870 --> 09:03.920
Reset.

09:05.700 --> 09:07.590
Let's adjust the size.

09:08.550 --> 09:10.440
To something like this.

09:11.430 --> 09:11.880
Yeah.

09:11.880 --> 09:16.890
And also I want to take damage trigger and I want to make it wider but slimmer.

09:17.460 --> 09:19.140
So maybe something like.

09:19.790 --> 09:20.810
This.

09:21.640 --> 09:22.510
All right.

09:22.930 --> 09:23.650
Cool.

09:24.010 --> 09:25.630
Uh, something else, I think.

09:25.630 --> 09:26.440
No.

09:26.470 --> 09:26.920
Oh, yeah?

09:26.920 --> 09:27.910
Well, detection.

09:28.360 --> 09:30.370
We need to increase walking distance.

09:31.570 --> 09:31.720
How?

09:31.720 --> 09:33.640
Maybe one will be just fine.

09:35.030 --> 09:35.390
Okay.

09:35.390 --> 09:37.430
Ground check is in front, so it's fine.

09:37.430 --> 09:39.320
Let's go ahead and see this.

09:43.230 --> 09:46.980
So there is an enemy walks just like any other enemy.

09:46.980 --> 09:49.140
Then I can just jump.

09:49.140 --> 09:52.380
It's going to enter the shell state without a body.

09:52.380 --> 09:55.110
And if I jump on it again, I'm gonna die.

09:55.410 --> 09:56.010
Cool.

09:56.010 --> 09:56.760
Very nice.

09:56.760 --> 09:59.160
Now let's make a buddy real quick.

09:59.490 --> 10:01.440
And for that, we're going to need a script.

10:01.440 --> 10:03.270
Enemy script.

10:04.630 --> 10:07.270
Enemy snail body.

10:10.420 --> 10:11.380
On this nail biter.

10:11.380 --> 10:14.710
We want to have a rotation and a bit of a velocity.

10:15.010 --> 10:19.360
We can take it from the enemy snail which has this information on the enemy script.

10:19.360 --> 10:23.020
We just need to make these variables protected over here.

10:23.840 --> 10:24.620
Protected.

10:26.480 --> 10:27.530
Protected.

10:29.250 --> 10:29.970
And.

10:31.430 --> 10:32.270
Protected.

10:32.480 --> 10:33.230
Okay.

10:37.440 --> 10:40.710
Now let's go to the enemy snail body.

10:42.920 --> 10:43.700
Over here.

10:43.700 --> 10:44.990
We need rigid body.

10:44.990 --> 10:47.570
So I'm going to do private rigid body 2d RB.

10:47.840 --> 10:52.880
And we need private float z rotation to set rotation on the object.

10:52.880 --> 11:01.550
Then we're going to need a public void set up by D which will take float y velocity for the death impact

11:01.550 --> 11:06.320
and also float z rotation to store the rotation we supposed to have on the body.

11:06.320 --> 11:08.120
And this is how we going to do this.

11:08.270 --> 11:09.680
And we need.

11:10.800 --> 11:15.660
We need component of the rigid body so we can do RB get component of a rigid body 2D.

11:16.960 --> 11:23.680
Then we're going to do RB dot velocity equals to a new vector to rb velocity dot x and y velocity.

11:23.680 --> 11:27.460
And also we want to save this rotation to this variable.

11:27.460 --> 11:33.850
So we're going to do this z rotation which refers to a variable we have over here.

11:33.850 --> 11:38.080
And it's going to be equals to z rotation which refers to variable.

11:38.080 --> 11:39.880
We pass through the parentheses.

11:41.280 --> 11:43.710
Now that we have it, we need update.

11:43.980 --> 11:47.850
And in the update we're going to do transform rotate.

11:48.780 --> 11:50.550
And here we need vector three.

11:50.550 --> 11:51.690
Let's do zero zero.

11:51.690 --> 11:54.210
And for the z we're going to do z rotation.

11:54.210 --> 11:56.310
Multiply by time dot delta time.

12:00.000 --> 12:02.820
And it's very similar to what we had on the enemy.

12:04.670 --> 12:08.390
When we handle this rotation, right?

12:08.960 --> 12:09.950
Very similar.

12:10.880 --> 12:11.840
All right.

12:11.840 --> 12:14.330
Now we have this method.

12:15.010 --> 12:21.160
And we can make a game object, put the script on, and then use this game object with a script to create

12:21.160 --> 12:25.690
a body, just like we did with a visual effect or bullets on other enemies.

12:26.770 --> 12:29.560
Let's go and set up a game object.

12:31.140 --> 12:33.000
So you know what I'm talking about.

12:33.030 --> 12:36.000
We're going to need graphics enemy.

12:37.270 --> 12:38.170
Uh, snail.

12:38.170 --> 12:41.020
Let's take the snail without shell.

12:41.470 --> 12:47.290
You're gonna switch layer to enemy, and I want it to be in front of the snail at all times.

12:47.290 --> 12:50.170
So I'm going to give it order in layer one.

12:53.900 --> 12:55.670
Now we need to add rigidbody 2D.

12:56.520 --> 13:04.440
Let's do, uh interpolate continuous and we want to add snail body script.

13:05.530 --> 13:06.190
Very good.

13:06.190 --> 13:07.600
So prefab is ready.

13:07.600 --> 13:08.950
We only need to change the name.

13:08.950 --> 13:11.560
I'm going to do enemy snail body.

13:12.270 --> 13:16.530
Then we can go to asset prefabs and just drag it here.

13:17.100 --> 13:22.860
Now we can remove it from the scene and on the enemies nail, we need to make a variable so we can drag

13:22.860 --> 13:23.430
it here.

13:23.430 --> 13:25.290
And then we can create an object.

13:26.750 --> 13:28.070
Let's go to script.

13:30.930 --> 13:32.880
Uh, I'm going to close all but this.

13:33.920 --> 13:40.580
Then I want to make a header, other snail details and we want to have serialized field.

13:40.580 --> 13:42.020
Private game object.

13:43.870 --> 13:45.130
Um, by the prefab.

13:45.130 --> 13:46.810
Actually, let's not use GameObject.

13:46.810 --> 13:51.790
Let's use script component so we can easily get access to it once we create it.

13:52.120 --> 13:53.950
I'm going to do enemy snail body.

13:56.340 --> 13:57.360
This can be private.

13:57.360 --> 13:59.010
Now we know how it works.

14:00.280 --> 14:02.800
And yeah, that's good for now.

14:02.800 --> 14:10.060
Let's go somewhere below and let's make a method private void create body.

14:11.530 --> 14:12.850
It's not going to be super simple.

14:12.850 --> 14:15.550
We're going to need GameObject, not we need.

14:15.550 --> 14:16.210
I'm so sorry.

14:16.210 --> 14:17.290
We need enemy.

14:18.130 --> 14:19.960
Um snail body.

14:20.760 --> 14:26.910
New body equals to instantiate, and this will create a game object of a body prefab.

14:26.910 --> 14:30.060
And at the same time it will get component of the script.

14:31.650 --> 14:36.360
We just need to make transform.position here and quaternion identity.

14:36.450 --> 14:37.800
And then.

14:39.630 --> 14:43.860
We're going to do a new body set up body for the Y.

14:43.860 --> 14:48.570
We're going to do death impact speed for the rotation.

14:49.110 --> 14:50.820
Uh, we can do random one.

14:50.820 --> 14:51.900
Yeah, let's do random.

14:52.320 --> 14:55.380
We need int random index.

14:55.950 --> 14:56.310
Now.

14:56.310 --> 14:57.540
Wait, how do we do that?

14:57.570 --> 14:59.670
I forgot, how did we do that on the enemy?

14:59.670 --> 15:03.000
We did random range from 50, right?

15:03.150 --> 15:05.070
Yeah, from 0 to 100.

15:05.070 --> 15:06.450
So this is what I'm going to do.

15:14.090 --> 15:15.320
Let's copy this.

15:15.320 --> 15:16.550
Go to enemy snail.

15:16.550 --> 15:17.720
Paste this in.

15:18.140 --> 15:19.250
We just need.

15:20.880 --> 15:23.040
To go here now and do.

15:23.670 --> 15:25.440
Death rotation.

15:26.210 --> 15:31.160
Speed multiplied by death rotation direction and it's going to be random.

15:31.190 --> 15:32.120
Very good.

15:32.120 --> 15:38.090
And just in case we want to destroy game object after we create one, uh, like after 10s, maybe.

15:38.090 --> 15:39.530
So let's do destroy.

15:41.120 --> 15:44.240
New body GameObject after 10s.

15:45.250 --> 15:49.420
Okay, now we need to call this method when we hit enemy for the first time.

15:49.420 --> 15:51.520
And we can do that on the animation.

15:51.820 --> 15:52.810
Let's go back.

15:55.320 --> 16:03.150
Here on enemy snail hit we have sprite where we flashing it white and I want to create body at this

16:03.150 --> 16:03.720
frame.

16:03.720 --> 16:08.640
And these frames are extra because I want it to look like we detached body from the shell.

16:08.640 --> 16:10.980
So I'm going to add the event over here.

16:11.250 --> 16:12.330
Choose.

16:13.090 --> 16:15.340
Method created by de.

16:16.600 --> 16:18.490
And these three will be deleted.

16:20.710 --> 16:23.290
Now let's go ahead and assign prefab.

16:24.920 --> 16:29.210
Our snail buddy over here and we can check this.

16:30.640 --> 16:32.020
Let's go to play mode.

16:35.120 --> 16:38.600
There is a snail and I'm going to jump on the head.

16:38.630 --> 16:41.750
You and we lost the body, by the way.

16:41.750 --> 16:44.450
We probably need to flip it, right?

16:44.840 --> 16:47.480
Uh, other than that, looks good to me.

16:48.110 --> 16:50.060
Okay, let's go flip the sprite.

16:50.150 --> 16:55.880
And also, uh, yeah, we can just do it here on the setup by the method.

16:55.880 --> 16:57.590
Let's go to definition.

16:57.770 --> 17:02.630
I'm going to do int facing direction plus int facing direction.

17:02.630 --> 17:06.440
And then over here we're going to do this we need.

17:07.180 --> 17:09.910
I want sprite renderer SR.

17:11.850 --> 17:15.810
Can get component here as I equals to get component of a sprite renderer.

17:16.320 --> 17:25.140
And then if facing direction is equals to one, then sr flip dot x flip x equals true.

17:25.170 --> 17:25.980
Okay.

17:25.980 --> 17:27.300
Now we're going to flip the body.

17:27.300 --> 17:28.140
This is good.

17:28.140 --> 17:30.330
We don't need to do anything else here.

17:30.600 --> 17:35.400
Going to go back to enemy snail and pass here facing direction.

17:37.950 --> 17:45.060
Other than that, we can set up movement of the shell when we hit it for the second time.

17:45.060 --> 17:47.520
So for that I want to speed up the movement.

17:47.520 --> 17:51.960
So for that we need serialized field, private float, max speed.

17:51.960 --> 17:54.240
Let's make it equals to ten by default.

17:54.360 --> 17:57.180
And then functionality is very simple.

17:57.180 --> 18:00.420
We just need to add another else if statement.

18:01.840 --> 18:05.170
Into this method when we jump on the head of the snail.

18:05.170 --> 18:10.450
So when we hit it for the first time, we stop the movement, we lose the body and then it waits there.

18:10.450 --> 18:11.320
Simple as that.

18:11.320 --> 18:13.960
When we do the second jump, we can do else if.

18:15.000 --> 18:16.470
Can move equals to false.

18:16.470 --> 18:19.260
So if not moving and has no body.

18:21.030 --> 18:23.340
Then let's fix it.

18:23.370 --> 18:24.180
Uh, wait a second.

18:24.180 --> 18:28.740
How it's supposed to be curly bracket here and now this one.

18:28.740 --> 18:33.690
Okay, so if we cannot move and we don't have a body, means there is just a shell there, and we can

18:33.690 --> 18:35.430
launch it left and right.

18:35.430 --> 18:37.860
So it's going to move real fast and bounce off the balls.

18:37.860 --> 18:39.090
This is how are we going to do that.

18:39.090 --> 18:41.550
Let's do anim set trigger.

18:43.040 --> 18:44.540
Of heat.

18:45.170 --> 18:47.930
And then we're going to do can move equals to.

18:48.690 --> 18:52.770
True so we can move again and move speed is going to be equals to max speed.

18:52.770 --> 18:54.810
So it's going to move real fast.

18:55.170 --> 18:59.070
Also when we flip the enemies I want to check if we detected the wall.

18:59.160 --> 19:02.190
So let's override the flip method.

19:04.700 --> 19:05.960
Now let's do it below.

19:06.080 --> 19:08.000
I'm going to do override flip.

19:08.620 --> 19:15.490
And here we're going to do if as by d equals to false means only shell is moving, then we're going

19:15.490 --> 19:17.530
to do anim set trigger.

19:18.390 --> 19:24.900
Of wall hit and this is going to work fine because we're not going to flip enemy when we flipping off

19:24.900 --> 19:25.320
the ledge.

19:25.320 --> 19:27.780
We're only going to flip enemy when we're hitting the wall.

19:27.780 --> 19:29.520
But I'm going to show you that in a minute.

19:29.520 --> 19:32.700
First, let's go ahead and check how it's working right now.

19:32.700 --> 19:35.310
YouTube speed up the shell or not okay.

19:36.890 --> 19:39.290
Let's save this and let's go back.

19:41.460 --> 19:42.750
Going to go to play mode.

19:49.170 --> 19:50.190
There is a snail.

19:50.190 --> 19:51.750
I'm going to jump on it now.

19:51.750 --> 19:54.690
It stands there with no body and I'm going to jump again.

19:54.690 --> 19:58.140
And it moves left and right and bounces just like that.

19:58.140 --> 19:59.910
It damages me as well.

20:00.120 --> 20:03.000
And if I jump on the top, I'm going to destroy it.

20:03.000 --> 20:04.770
Very nice and very fun one.

20:04.770 --> 20:06.000
I like it a lot.

20:06.210 --> 20:11.700
And the last adjustment we need to do is to fix the behavior of the ledge.

20:12.180 --> 20:16.080
Uh, first we need to make it heavier so it's going to fall faster.

20:16.080 --> 20:18.090
Let's do gravity scale three.

20:18.090 --> 20:24.330
And also we don't want it to rotate because sometimes the snail might just move off the ledge.

20:24.330 --> 20:31.170
Not here where it's supposed to die, but somewhere here, let me actually show you that I'm going to

20:31.170 --> 20:32.370
make another snail.

20:32.370 --> 20:33.750
Place it here.

20:33.990 --> 20:36.600
I'm going to switch off the spike ball.

20:39.160 --> 20:40.420
And let me.

20:42.520 --> 20:44.320
Erase this platform over here.

20:44.320 --> 20:45.100
Okay.

20:46.070 --> 20:48.020
So now, what happens when we.

20:49.760 --> 20:55.850
Kick it and then kick it again, and it just goes here and there, and we need to switch off this ability

20:55.850 --> 20:56.750
for the shell.

20:56.750 --> 20:59.600
So we're going to go back to scripts of a snail.

21:01.430 --> 21:06.770
And we need to change condition in which it can flip or the is not ground detected.

21:07.160 --> 21:13.070
We can simply add here and has body just like that.

21:13.070 --> 21:16.700
If it looks a bit confusing, what we can do is to add bool.

21:17.710 --> 21:20.710
Bull can flip from ledge.

21:20.710 --> 21:23.440
It's going to be equals to no is ground detected.

21:24.610 --> 21:26.320
And has body.

21:26.960 --> 21:31.040
And now we can use it here and it's a bit cleaner and more understandable.

21:31.130 --> 21:32.390
Can flip from ledge.

21:33.330 --> 21:39.510
All right, so the flip of the latch will work only if we have body in the snail.

21:39.570 --> 21:40.560
Very good.

21:40.590 --> 21:42.090
Now let's go ahead and see this.

21:42.120 --> 21:43.320
It's going to have a couple of bugs.

21:43.320 --> 21:44.880
We're going to fix some real quick.

21:44.910 --> 21:48.360
Let me just switch off the fire and checkpoint.

21:49.720 --> 21:50.380
Okay.

21:53.880 --> 21:54.360
You.

21:55.160 --> 21:57.290
You and it goes off the ledge.

21:57.350 --> 22:03.320
I want to switch off rotation because I believe if this platform is higher then this snail might really

22:03.320 --> 22:05.210
twist it like.

22:05.900 --> 22:07.910
So give me a second.

22:12.990 --> 22:14.190
Now imagine that.

22:19.090 --> 22:20.110
Wow.

22:21.070 --> 22:21.580
Yeah.

22:21.580 --> 22:28.630
So we need to switch off Z rotation over here, and let's, uh, let's delete the extra.

22:28.630 --> 22:29.860
Let's take this one.

22:29.860 --> 22:31.300
Switch off z rotation.

22:31.300 --> 22:33.520
I'm going to bring level back to what it was.

22:35.220 --> 22:38.400
Something like that, I believe I don't remember lets me do control Z.

22:39.080 --> 22:39.350
Yeah.

22:39.350 --> 22:40.070
Like so.

22:41.770 --> 22:44.170
So I'm going to delete the extra here.

22:44.170 --> 22:45.550
I'm going to take this one.

22:45.550 --> 22:47.320
Give it freeze rotation Z.

22:47.320 --> 22:53.050
And also you probably noticed it sticked to the wall for the same reason that player had.

22:53.050 --> 22:56.620
So we can fix it in the same way we did for the player.

22:56.620 --> 23:04.030
We just need to go to the collider and attach player material over here so it will not stick to walls.

23:04.030 --> 23:11.080
Now let's go ahead and remove this platform over here and I'm going to see how it does it behaves.

23:12.640 --> 23:14.920
It flips off the ledge when it has a body.

23:15.520 --> 23:17.740
Then when I pick off the body.

23:18.670 --> 23:23.200
It flips off the wall, but it does not flip off the ledge and it just falls there.

23:23.200 --> 23:23.920
Very nice.

23:23.920 --> 23:24.880
Just what we need.

23:25.900 --> 23:31.960
The last adjustment I want to do is to destroy the enemy when it goes into a dead zone.

23:32.700 --> 23:35.340
Uh, so let's go to dead zone.

23:36.760 --> 23:37.750
Over here.

23:37.750 --> 23:40.060
And we're going to check enemy.

23:40.060 --> 23:42.670
Enemy equals to get component of the enemy.

23:42.670 --> 23:46.960
And if enemy is not equals to null then enemy die.

23:47.530 --> 23:48.610
This is what we need.

23:51.230 --> 23:55.580
And lastly, I think we do not destroy the game object when we kill the enemy.

23:55.910 --> 23:57.500
So this is what we need to fix.

23:58.460 --> 24:00.740
Let's go to the definition of a die method.

24:02.240 --> 24:03.320
And over here.

24:03.320 --> 24:05.150
I want to do destroy.

24:06.730 --> 24:10.630
GameObject after 10s should be fine.

24:12.430 --> 24:13.060
All right.

24:13.060 --> 24:14.410
This is supposed to be good.

24:14.440 --> 24:18.160
I think we are ready to go to the next video.

24:18.700 --> 24:20.020
I'll see you there.
