WEBVTT

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

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

00:01.460 --> 00:04.250
In this one we're going to make a wall slide ability.

00:04.250 --> 00:06.440
And then one after that we're going to make a wall jump.

00:06.440 --> 00:09.440
But first let's do a wall slide to make a wall slide.

00:09.440 --> 00:10.820
First of all we need some walls.

00:10.820 --> 00:16.850
So I'm going to duplicate this platform move it here and then stretch it with the rack tool to make

00:16.850 --> 00:18.770
it something like this.

00:21.200 --> 00:21.620
Yeah.

00:21.620 --> 00:23.240
And then let me make another one.

00:24.160 --> 00:25.570
And place it here.

00:28.560 --> 00:29.430
Maybe.

00:29.610 --> 00:30.090
Yeah.

00:30.090 --> 00:30.840
Something like this.

00:30.840 --> 00:32.370
Supposed to work, I guess.

00:35.100 --> 00:39.600
Now, if I try to jump on the wall right now, I'm not going to slide, especially if I'm holding the

00:39.600 --> 00:41.100
key to fix it.

00:41.130 --> 00:44.430
We need to add a physics material to the player.

00:45.480 --> 00:54.930
We can click right button over here, create 2D physics material 2D and let's call it player material.

00:54.960 --> 00:55.770
Okay.

00:55.770 --> 00:58.140
Now friction should be zero here.

00:58.140 --> 00:59.550
Let's make it a zero.

00:59.550 --> 01:05.730
And then let's select the player and drag player material on the capsule Collider like that.

01:05.880 --> 01:06.750
Very good.

01:06.750 --> 01:08.250
Now we can go to play mode.

01:08.760 --> 01:11.310
And I'm just going to try to slide again.

01:11.310 --> 01:12.630
And I'm sliding.

01:12.660 --> 01:13.680
Very nice.

01:13.710 --> 01:19.290
Now next step would be to detect the wall and enter some sort of wall slide behavior.

01:19.290 --> 01:23.550
For example player supposed to slide a bit slower than he does it right now.

01:24.030 --> 01:27.690
For that, first of all we need to make a wall detection.

01:28.940 --> 01:30.800
Let's select player script.

01:31.980 --> 01:36.120
Then on the collision over here, we can make another private boolean.

01:37.810 --> 01:43.060
Private wall is wall detected and I think we need wall check distance.

01:43.060 --> 01:44.650
So I'm going to make it over here.

01:44.650 --> 01:48.910
Sterilize field private float wall check distance.

01:49.090 --> 01:50.050
Just like that.

01:52.200 --> 01:54.450
Let's go to handle collision method.

01:54.990 --> 01:57.000
We can click go to definition.

01:57.000 --> 02:03.240
And over here we need to make Esbl detected equals to physics 2D dot raycast.

02:03.240 --> 02:05.250
And last time we did raycast down.

02:05.250 --> 02:06.930
But now we need to do it to the right.

02:06.930 --> 02:13.830
So transform position vector two dot right multiplied by facing direction.

02:13.830 --> 02:17.040
Because we want to flip raycast together with a character, right?

02:17.040 --> 02:22.500
Because otherwise if we don't do this then raycast will work only to the right side.

02:22.920 --> 02:26.640
Then let's type wall check distance and what is ground.

02:26.640 --> 02:27.690
Just like that.

02:28.050 --> 02:28.740
Very nice.

02:28.740 --> 02:29.850
Let's save it.

02:30.060 --> 02:33.750
And let's go to gizmos and draw a line so we can see it.

02:33.990 --> 02:40.050
Gizmos draw a line from transform position to new vector two.

02:40.050 --> 02:42.720
And here we need transform position.

02:42.720 --> 02:48.540
Plus let's open parentheses and type wall check distance multiplied by facing direction.

02:48.540 --> 02:50.790
So again we're going to flip the gizmo as well.

02:50.790 --> 02:53.010
And for the Y we just need.

02:53.760 --> 02:55.620
Transform position dot y.

02:58.110 --> 02:58.980
Uh, give me a second.

02:58.980 --> 02:59.850
Something is wrong.

02:59.850 --> 03:00.060
Oh.

03:00.060 --> 03:01.680
Over here, dot x.

03:04.130 --> 03:05.870
Okay, so this is how it looks.

03:08.810 --> 03:14.510
Now let's just save it and go to unity and make sure it is working correctly.

03:14.960 --> 03:16.280
We're going to choose.

03:16.280 --> 03:19.760
We're going to set wall check distance to something like zero point.

03:20.480 --> 03:21.680
65.

03:21.710 --> 03:23.630
Let me try to see it.

03:23.630 --> 03:24.680
Oh, perfect.

03:24.680 --> 03:28.340
So this is the wall check distance, and we just need to set it to something like this.

03:28.340 --> 03:31.010
So 65 is just a good value.

03:33.210 --> 03:39.030
Now let's go to play mode and let's open debug mode so we can see we'll.

03:41.490 --> 03:44.190
Detected Boolean over here is well detected.

03:44.190 --> 03:47.460
I'm going to walk up to the wall and we'll detect it.

03:47.790 --> 03:49.500
Or in a way not detected.

03:49.500 --> 03:51.810
Detected not okay.

03:52.930 --> 03:55.960
Now let's make a wall slide behavior.

03:55.990 --> 03:57.400
We're going to open player.

03:57.550 --> 04:01.450
And maybe somewhere before we handle the movement.

04:01.480 --> 04:03.340
Let's do handle.

04:04.000 --> 04:04.750
Handle.

04:04.750 --> 04:06.190
Wall slide.

04:07.320 --> 04:11.130
Now we need to click alt enter and generate method handle.

04:11.130 --> 04:11.400
Wall.

04:11.400 --> 04:11.880
Slide.

04:12.360 --> 04:13.320
Nice.

04:13.350 --> 04:18.720
Now over here we just need to check if wall detected.

04:20.200 --> 04:21.610
Means we detected the wall.

04:21.640 --> 04:22.600
This is good.

04:22.600 --> 04:29.860
And if we move it down because we want to slow down the player only when he like falling down.

04:29.860 --> 04:30.220
Right.

04:30.220 --> 04:31.030
So we're going to do.

04:31.030 --> 04:33.850
And RB velocity dot y less than zero.

04:33.880 --> 04:35.620
Then we will slide in.

04:35.620 --> 04:37.360
So let's just do debug log.

04:38.140 --> 04:40.210
We'll slide in now.

04:41.190 --> 04:41.670
For now.

04:41.670 --> 04:43.260
Let's just see how it's working.

04:43.710 --> 04:44.820
I'm going to go back.

04:46.030 --> 04:46.270
Mm.

04:47.520 --> 04:49.410
Open console, go to play mode.

04:53.060 --> 04:54.680
And I'm going to stand next to the wall.

04:54.680 --> 04:55.730
No debug message.

04:55.730 --> 04:56.750
I'm going to jump.

04:56.750 --> 05:00.950
No debug message, and only when I'm falling there is a debug message.

05:00.950 --> 05:02.300
So this is good.

05:02.300 --> 05:05.330
Now let's try to slow down the character.

05:05.630 --> 05:09.890
I'm going to do RB velocity equals to a new vector two for the x.

05:09.890 --> 05:11.060
We're not going to change anything.

05:11.060 --> 05:12.950
So rb velocity dot x.

05:12.950 --> 05:16.040
And for the y we're going to take rb dot velocity dot y.

05:16.040 --> 05:18.830
And we're going to multiply it by 0.5 f.

05:18.830 --> 05:21.890
So character is going to slide down slower.

05:21.890 --> 05:27.140
This one basically is like um taking 50% of the velocity that we currently have.

05:27.140 --> 05:28.370
I'm going to save it.

05:33.060 --> 05:39.900
Let's go to play mode and let's try to jump on the wall and we slowly sliding down.

05:40.440 --> 05:41.310
Very nice.

05:41.340 --> 05:47.460
We're going to improve it a bit, but later on as of now let's just add animation so it looks good.

05:47.760 --> 05:53.190
Uh, on the animation we're going to select animator and add new Clip.

05:56.430 --> 06:01.230
Over here you're going to make layer wall slide.

06:01.230 --> 06:02.430
Let's save it.

06:04.180 --> 06:05.650
Then we need to find graphics.

06:05.650 --> 06:07.870
Main character virtual GUI.

06:07.990 --> 06:12.130
Here we have wall jump sprite sheet and we're going to take all of them.

06:12.340 --> 06:16.090
Place them on the animation and set sample rate to 15.

06:16.660 --> 06:17.620
Nice.

06:17.980 --> 06:21.610
Now let's go to assets and to the animator.

06:21.970 --> 06:24.880
And over here we have this animation player wall slide.

06:25.000 --> 06:31.570
We're going to transfer to this animation only if we jump in or fall in, because we don't want to enter

06:31.570 --> 06:36.820
wall slide from any other animation, like if we're walking or standing, we do need to enter wall slide

06:36.820 --> 06:39.160
animation only when we jump in on the wall.

06:39.700 --> 06:41.260
Let's make a boolean.

06:42.210 --> 06:44.460
Is wall detected.

06:46.700 --> 06:52.310
And we're going to make transition to wall slide with a condition is well detected.

06:52.310 --> 06:52.910
True.

06:52.910 --> 06:56.450
Let's uncheck exit time and transition duration set to zero.

06:56.450 --> 07:00.290
Now it's going to work like that, but not entirely correct.

07:00.290 --> 07:03.800
But still I want to show you how it's going to work so you understand what we're doing here.

07:03.800 --> 07:07.130
So as of now, if we walk to the wall nothing is going to happen.

07:07.130 --> 07:09.890
But if we jump, we're going to enter.

07:10.340 --> 07:12.590
Oh wait, I forgot to update the boolean.

07:12.590 --> 07:13.490
I'm sorry.

07:13.490 --> 07:14.540
Let's do this.

07:14.540 --> 07:16.640
Let's take this name over here.

07:16.670 --> 07:17.930
Go to player.

07:19.690 --> 07:22.840
Let's find a handle animations.

07:22.840 --> 07:25.930
And over here we need enum set bool.

07:27.990 --> 07:30.870
He's well detected to is well detected.

07:30.870 --> 07:31.860
Just like that.

07:31.860 --> 07:32.610
Nice.

07:32.610 --> 07:34.350
Now let's save it and go back.

07:37.100 --> 07:39.620
And let's see this in the action.

07:41.830 --> 07:43.120
I'm going to walk up to the wall.

07:43.120 --> 07:44.350
Nothing is going to happen.

07:44.350 --> 07:50.950
But if I jump, I'm entering wall slide and it's okay to have this animation when we going down, but

07:50.950 --> 07:53.890
when we going up, we don't need to have a wall slide animation.

07:53.890 --> 08:00.070
So over here we're going to add the same condition as we had in the method with the RB velocity dot

08:00.070 --> 08:00.520
y.

08:03.710 --> 08:04.400
Over here.

08:04.400 --> 08:07.670
So we're going to add basically the same condition in the animator.

08:07.730 --> 08:11.090
Let's go back hit plus on the conditions.

08:11.270 --> 08:11.960
Find why.

08:11.960 --> 08:14.240
Velocity less than zero.

08:19.220 --> 08:23.810
We also need to exit this animation, and that would be done when we detect in the ground.

08:23.810 --> 08:28.490
If we came to the ground, we are no longer wall sliding and we need to exit the animation.

08:28.490 --> 08:33.410
So we're going to choose this condition over here and click is grounded.

08:33.410 --> 08:34.010
True.

08:34.340 --> 08:36.050
Let's uncheck exit time.

08:36.640 --> 08:39.160
And now let's go and try again.

08:41.150 --> 08:42.170
So we can see.

08:42.170 --> 08:43.430
I'm going to the wall.

08:44.240 --> 08:45.290
Nothing is happening.

08:45.290 --> 08:51.200
I'm jumping and I'm entering one slide only when I'm going down and then I'm going back to the idle

08:51.200 --> 08:52.070
animation.

08:52.160 --> 08:53.240
Very cool.

08:53.240 --> 09:00.410
Now, if I go off the wall with my movement key, just like that, we can see I'm still in a wall slide

09:00.410 --> 09:02.870
animation, which is not really good.

09:02.870 --> 09:05.840
So we need to fix it and we can fix it easily.

09:05.840 --> 09:13.790
By setting alternative condition for the animation transition, we can just select it again make transition

09:13.790 --> 09:14.690
to jump fall.

09:14.690 --> 09:17.930
And this will work sort of like or condition.

09:17.930 --> 09:20.990
We check both and you do this or this.

09:20.990 --> 09:23.990
And for the second condition we're going to check.

09:25.060 --> 09:32.260
If Isabelle detected false, and if it's a false, then we're going to exit this animation state.

09:32.290 --> 09:34.390
Now let's go back and try this again.

09:34.390 --> 09:39.550
Now we can get on the wall and we can get off the wall just by pressing movement to the opposite side

09:39.550 --> 09:40.180
of the wall.

09:40.180 --> 09:45.190
The only issue is that we can see that sort of a flip when we get off the wall, and it looks like a

09:45.190 --> 09:51.130
glitch, and that happens because we getting off the wall and still we detecting a wall for a little

09:51.130 --> 09:51.400
bit.

09:51.400 --> 09:55.090
And we have that wall slide animation.

09:55.660 --> 09:57.130
When we are off the wall.

09:57.130 --> 10:03.820
It's very easy fix, although to be honest, I spent two days on finding whites like that and solution

10:03.820 --> 10:06.610
was super simple, but it took me a long time to find it.

10:06.640 --> 10:07.240
Yeah.

10:07.240 --> 10:13.660
So before we apply the solution, let's fix another issue, which is also very important at the moment.

10:13.960 --> 10:17.590
I can run into the wall just like that, and I don't really like it.

10:17.590 --> 10:23.170
So I want to stop movement of the character if he's facing the wall and if he's facing the wall, we're

10:23.170 --> 10:26.200
going to flip him only when we have X input.

10:27.310 --> 10:31.150
Let's go back to the scripts and.

10:32.080 --> 10:34.420
Over here in the.

10:35.500 --> 10:41.590
Clip controller over here, where we handle flip instead of velocity of the rigid body, let's use x

10:41.590 --> 10:42.310
input.

10:46.280 --> 10:47.180
X input.

10:47.180 --> 10:53.450
Now, flip function depends on the input of the player and not on the velocity, which is actually better

10:53.450 --> 10:54.260
than it was.

10:54.260 --> 10:59.300
Now let's go to handle movement over here and add simple if statement.

10:59.300 --> 11:02.630
We're going to type if wall detected.

11:03.930 --> 11:05.340
Then return.

11:05.340 --> 11:10.380
If you see something like this for the first time, I'm just going to say that return basically means

11:10.380 --> 11:11.760
interrupt the function.

11:11.760 --> 11:16.140
If we return from a method, nothing after return will be applied.

11:16.140 --> 11:17.190
It will not work.

11:17.190 --> 11:18.120
Simple as that.

11:18.120 --> 11:22.530
So we check if we detect in the wall, then we return from a movement means if we detect in the wall

11:22.530 --> 11:23.820
then we cannot move.

11:23.820 --> 11:28.200
It would be very similar to have something like this.

11:28.200 --> 11:32.820
Yeah, but I just like it better with the return because in this way it's a bit easier to understand.

11:32.820 --> 11:34.020
So this is what we're going to have.

11:34.020 --> 11:36.870
So we changed the flip method and we changed handle movement.

11:36.870 --> 11:39.330
Let's save this and let's go back to unity.

11:40.610 --> 11:43.130
Now when we walking up to the wall.

11:43.760 --> 11:47.990
We cannot move, but we can move to the opposite side because we flip and move.

11:48.110 --> 11:49.070
Very good.

11:49.070 --> 11:50.300
I like it very much.

11:50.630 --> 11:54.980
Uh, something else there we can see that character is behind the wall while he is standing.

11:54.980 --> 11:56.720
This is not as important right now.

11:56.720 --> 11:58.220
I promise to you, we're going to fix it later.

11:58.220 --> 12:03.380
Once we draw the level parts, I'm going to explain why he's behind the image and so on.

12:03.380 --> 12:08.780
Although if you really want to fix it quickly, you can go to animator and choose Order and Layer one

12:08.780 --> 12:10.190
over here and it's going to be fine.

12:10.190 --> 12:13.730
But I'm going to talk more about sorting layers and ordering layers later on.

12:13.730 --> 12:16.610
So this is just a quick fix for you, right?

12:16.610 --> 12:17.150
One.

12:18.390 --> 12:24.660
Now we cannot move when we try to move into the wall, but each with the flip is still there, right?

12:24.660 --> 12:27.540
Look, I'm going to jump on the wall and I'm going to try to get off the wall.

12:27.540 --> 12:33.360
And there is this sort of a glitch, a very fast one, but it's visible, it's noticeable, and it's

12:33.360 --> 12:36.810
supposed to be smooth and nice and to fix it.

12:37.980 --> 12:40.170
First, let me explain what is happening there.

12:40.170 --> 12:46.710
So when we get an off the wall, the boolean that says is well detected or not.

12:47.850 --> 12:52.620
Is not yet updated by the time we updating the animation.

12:53.150 --> 12:54.740
Yeah, something like that.

12:54.740 --> 13:00.350
Over here in the handle animation we pass is well detected to the animation boolean.

13:00.350 --> 13:06.050
And the deal is that when we get off the wall, it's kind of like information is not updated fast enough.

13:06.050 --> 13:09.230
Or maybe like information was updated long time ago.

13:09.230 --> 13:14.510
And because of that we'll detect it still says we detect in the wall even though we are not detecting

13:14.510 --> 13:15.410
the wall anymore.

13:15.410 --> 13:20.780
And because of that, we can still see that sort of a glitch with the animation fix is very simple,

13:20.780 --> 13:24.890
although again, I spent two days to find a solution for this.

13:25.340 --> 13:31.190
Uh, we need to take this handle collision method in the update and move it closer to the handle animation.

13:31.190 --> 13:35.900
So between collision and animations we have as less code as possible.

13:35.900 --> 13:36.380
For that.

13:36.380 --> 13:40.700
We're just going to take this method and move it down over here just like that.

13:40.700 --> 13:46.160
So make sure you have input wall slide movement flip collision animation.

13:46.160 --> 13:48.800
If something changes in the future I'll let you know.

13:48.800 --> 13:50.930
But as of now, this is just good.

13:51.260 --> 13:54.410
And let's save it and let's go back to unity and let's see it again.

13:54.410 --> 13:57.350
And I'm sure you'll spot the difference right away.

13:57.350 --> 14:03.500
Now I'm going to jump on the wall and I'm going to get off the wall and it smooth and nice without the

14:03.500 --> 14:04.310
glitch over there.

14:04.310 --> 14:05.330
You can see that right?

14:05.330 --> 14:06.410
Very smooth and nice.

14:06.410 --> 14:13.700
So now we have uh, sort of a super fresh information about wall detection when we updating the animator.

14:13.700 --> 14:15.650
And that solves the problem.

14:15.920 --> 14:16.700
Very nice.

14:16.700 --> 14:17.510
I love it so much.

14:17.510 --> 14:18.920
And we cannot run into the wall.

14:18.920 --> 14:20.000
Also super cool.

14:20.000 --> 14:25.460
There is an issue with a jump when we, uh, wall sliding, but that is just not yet fixed.

14:25.460 --> 14:29.450
We're going to fix it when we're doing a wall jump, because when we press in space and doing wall slide,

14:29.450 --> 14:30.800
we're going to go to wall jump.

14:30.800 --> 14:32.930
And this will not happen at all.

14:32.930 --> 14:33.380
All right.

14:33.380 --> 14:35.330
There is something else I would like to do.

14:36.230 --> 14:37.850
To improve the wall slide.

14:38.090 --> 14:39.950
We're going to go to player script.

14:40.160 --> 14:47.180
And in the handle wall slide we're going to do similar uh functionality like we did over here with the

14:47.570 --> 14:48.590
wall detected.

14:48.590 --> 14:52.040
But we're going to create a local variable.

14:52.460 --> 14:52.910
Um.

14:53.840 --> 14:56.240
If you never saw local variables before.

14:56.240 --> 15:02.720
It's basically like any other variable in the script, but these variables are available to the entire

15:02.720 --> 15:07.400
script, and local variable inside of a method is available only to the method.

15:07.400 --> 15:13.370
So we can type here bool can wall slide equals to and we can.

15:13.370 --> 15:20.690
Wall slide is going to be true only if is wall detected and rb velocity dot y is less than zero.

15:20.690 --> 15:21.380
Okay.

15:21.380 --> 15:24.320
Now let's go here and type.

15:24.320 --> 15:26.630
If Campbell slide equals to false.

15:26.630 --> 15:28.580
If we cannot slide we return.

15:28.820 --> 15:31.010
So logic is very similar to what it was before.

15:31.010 --> 15:33.920
It's just written sort of in an opposite way.

15:33.920 --> 15:36.920
You know uh, like we make an a boolean.

15:36.920 --> 15:40.700
That will be true only if all detected and velocity is below zero.

15:40.700 --> 15:46.070
But if this boolean is false means we cannot slide anymore and we're supposed to return from this method,

15:46.070 --> 15:47.900
and this code will not be applied.

15:48.350 --> 15:50.930
All what we need to do now is to delete this if statement.

15:50.960 --> 15:57.020
Now it is useless and it's going to work in a very same way, but it's just written differently and

15:57.020 --> 15:58.820
maybe it does not really make sense to you.

15:58.820 --> 15:59.810
Why are we doing it like that?

15:59.810 --> 16:05.240
But I promise to you it is better because, um, we're going to add one more condition to the wall slide

16:05.240 --> 16:08.600
later on, and it's easier to add condition over here.

16:08.600 --> 16:14.480
And then just read console slide Boolean when you check in, what function does instead of reading an

16:14.480 --> 16:19.730
if statement with triple condition and trying to understand what's the purpose of this if statement?

16:19.730 --> 16:26.270
Basically, the main goal of this is to make it more readable, because now you can check if what if

16:26.270 --> 16:29.390
can wall slide are okay and what is the condition for wall slide.

16:29.390 --> 16:31.970
Oh this is a condition for wall slide okay I get it.

16:31.970 --> 16:36.320
But when you have an if statement like we had before and you don't remember what you did in this method,

16:36.320 --> 16:40.010
because I promise to you, after a couple of days you will forget what is written here.

16:40.010 --> 16:41.720
So for now we're going to keep it just like that.

16:41.720 --> 16:43.970
And I want to add one more improvement here.

16:43.970 --> 16:48.890
I want to make another local variable float y modifier.

16:48.890 --> 16:53.210
And we're going to use this modifier over here instead of hard coded number.

16:53.570 --> 16:58.460
Uh we're going to type float y modifier equals to uh point.

16:58.760 --> 17:01.610
Let's do 05F something really small.

17:01.610 --> 17:04.910
Now my goal is to apply y modifier over here.

17:06.190 --> 17:09.040
And I want to change this modifier.

17:09.040 --> 17:15.040
If we press in key down because I want to make character slide faster, if we press and down so we can

17:15.040 --> 17:16.960
have quicker movement around the map.

17:16.960 --> 17:20.020
For that I need to know the y input we have.

17:20.020 --> 17:23.320
So we're going to type here private float y input.

17:23.770 --> 17:27.580
And then we're going to go back to handle input.

17:27.910 --> 17:29.350
Go to definition.

17:29.500 --> 17:30.670
Let's open this.

17:30.670 --> 17:32.830
And over here we're going to do y input.

17:34.300 --> 17:35.770
Equals to input.

17:35.770 --> 17:36.790
Get axis.

17:36.790 --> 17:37.420
Raw.

17:37.840 --> 17:38.800
Vertical.

17:39.770 --> 17:40.340
Nice.

17:40.340 --> 17:46.970
Now we have y input, we can easily read it and we can keep it like that and do something like this.

17:47.000 --> 17:54.410
If y input is less than zero means we press it down, then y modifier equals to one, right?

17:54.410 --> 17:55.550
This is what we can do.

17:56.060 --> 17:58.640
And let's just go there and make sure it's working.

17:58.640 --> 18:00.920
And then I'm going to show you another way to write it.

18:00.920 --> 18:03.320
That is a bit cleaner I would say.

18:03.320 --> 18:05.510
So now I'm jumping on the wall.

18:05.510 --> 18:08.120
I'm sliding slower than it was before.

18:08.120 --> 18:11.210
And if I press key down I'm sliding fast.

18:11.210 --> 18:15.860
So this allows me to do some sort of, you know, ju ju.

18:16.280 --> 18:20.810
So I have more control of the character, which is very important in the platformer game.

18:22.120 --> 18:24.790
Now this is working just like that, and I kind of like it.

18:24.850 --> 18:28.990
There is another way to write it, and I want you to learn how to write it in a different way.

18:28.990 --> 18:33.610
Maybe you will not remember how to use it, but next time I'm using it, you'll know how does it work

18:33.610 --> 18:34.720
and what is it at all?

18:34.720 --> 18:40.810
So we could do something like this if y input is less than zero.

18:41.670 --> 18:42.900
Then.

18:44.380 --> 18:51.340
Why modifier equals to one else why modifier equals to 0.05 f.

18:51.340 --> 18:52.690
And this would be an if statement.

18:52.690 --> 18:58.390
And there is a way to write the very similar if statement but in one line of code, and it will do the

18:58.390 --> 19:01.750
same functionality, but it will take less of a space.

19:01.750 --> 19:02.920
How does it work?

19:02.920 --> 19:08.920
We go to float y modifier and before we assign the value, we can sort of ask a question and if answer

19:08.920 --> 19:11.800
to the question will be yes, then it will take one value.

19:11.800 --> 19:15.100
If answer will be no, then it will take another value.

19:15.100 --> 19:16.240
This is how it works.

19:16.240 --> 19:20.140
We type here y input less than zero question mark.

19:20.140 --> 19:21.820
So this is the question over here.

19:22.150 --> 19:25.840
Then if yes then use one.

19:25.840 --> 19:30.700
If no then use 0.05 F.

19:30.700 --> 19:33.550
And this is sort of a shortened if statement.

19:33.550 --> 19:36.880
We can delete this now and it will work same as before.

19:36.880 --> 19:38.800
Just want to explain once more.

19:39.220 --> 19:46.300
So value of this modifier will be equals to either 1 or 0 five.

19:46.300 --> 19:53.470
And it will depend on the condition over here if y input is less than zero if we press it down then

19:53.470 --> 19:54.400
answer is yes.

19:54.400 --> 19:56.140
And we're using first value over here.

19:56.140 --> 19:57.460
That is after question mark.

19:57.460 --> 19:58.630
It will be one.

19:58.630 --> 20:00.790
If answer is no.

20:00.790 --> 20:04.630
If this is wrong then we're going to use um.

20:05.770 --> 20:07.900
While you after the columns over here.

20:07.900 --> 20:09.940
So it's going to be this value.

20:10.990 --> 20:11.650
Okay.

20:12.010 --> 20:12.760
Yeah.

20:12.760 --> 20:16.210
So let's just move it there and clean this up a bit.

20:16.210 --> 20:19.450
Now we have a new method which is clean and nice and understandable.

20:19.450 --> 20:21.760
And this works same as before.

20:21.880 --> 20:27.910
And also it's not only clean method but also it's going to be good foundation for us to extend that

20:27.910 --> 20:29.860
method in the future if we need to.

20:29.980 --> 20:30.940
Okay.

20:30.940 --> 20:31.750
Good.

20:31.750 --> 20:33.010
I'll see you in the next video.
