WEBVTT

00:00.040 --> 00:06.600
Now we need to make transition this transition through our code so we can see if we select our player

00:06.600 --> 00:12.880
GameObject in the hierarchy, we can see that an animator component is attached to this player GameObject.

00:13.040 --> 00:17.080
So we do know that we need a reference of this animator component.

00:17.080 --> 00:22.040
Then we can just set this parameter depending upon what player is really doing.

00:22.160 --> 00:26.160
So what we will do we need a reference of this animator component.

00:26.160 --> 00:31.080
So let's open up our player script and let's grab the reference first of it.

00:31.080 --> 00:34.800
So we will go to top of our class and let's make it private.

00:34.800 --> 00:36.120
It doesn't need to be public.

00:36.120 --> 00:39.240
So we're going to make a private uh private.

00:39.240 --> 00:41.920
And the component we're looking for is animator.

00:41.920 --> 00:47.800
So we're going to type this animator and let's call this one animator something like that.

00:48.000 --> 00:50.560
And let's go to this start function.

00:50.560 --> 00:54.320
And let's grab the reference of that animator component.

00:54.320 --> 01:00.160
So we're going to use this animator equal to this dot get component.

01:00.160 --> 01:02.920
And the component we're looking for is animator.

01:02.920 --> 01:08.520
So we're going to type this animator and let's make first packet then close that up with semicolon.

01:08.960 --> 01:11.960
Uh so basically this dot get component Animator.

01:11.960 --> 01:17.960
Basically we simply taking this animator component and we storing that animator component into this

01:17.960 --> 01:21.160
animator variable we created up over here.

01:21.160 --> 01:24.440
As you can see we storing that into this animator.

01:24.480 --> 01:29.560
Now we have the reference and we are ready to uh, switch the animation.

01:29.800 --> 01:35.040
So what we will do, we're going to use this movement parameter in order to switch up the animation.

01:35.040 --> 01:42.240
And we do know that this movement right over here, it can be minus one zero or plus one means this

01:42.240 --> 01:44.120
player can go left and right.

01:44.120 --> 01:50.000
And if we press the space key, then, uh, we just gonna play the jump animation clip.

01:50.000 --> 01:56.320
So we basically want to use this movement parameter in order to play our running animation clip.

01:56.320 --> 01:57.440
So let's do it.

01:57.440 --> 02:03.650
So we will move over to this inside this update function and let's do it over here in the bottom.

02:03.810 --> 02:05.410
So let's make this if condition.

02:05.410 --> 02:08.170
Let's make first bracket and some curly brackets.

02:08.370 --> 02:11.690
So what we want to do over here what we want to check.

02:12.130 --> 02:15.410
We want to check if our movement is greater than zero.

02:15.730 --> 02:22.170
And we do know that if we start moving to the right direction then then movement is going to be something

02:22.170 --> 02:22.970
like one.

02:23.410 --> 02:28.090
So over here we're going to check if our movement is greater than zero.

02:28.130 --> 02:31.610
If it's basically means that our player is moving.

02:31.610 --> 02:37.530
But the problem is that if we start moving to the left direction and left direction, then this movement

02:37.530 --> 02:39.930
right over here, it's going to be minus one.

02:40.210 --> 02:42.890
So minus one is not greater than zero.

02:43.330 --> 02:43.890
Zero.

02:44.090 --> 02:44.490
Zero.

02:44.530 --> 02:46.970
If it's basically smaller than zero.

02:46.970 --> 02:50.170
But we do know that we are moving to the left direction.

02:50.170 --> 02:52.570
So we need to play the run animation clip.

02:52.650 --> 02:55.290
So what we basically what we can do.

02:55.490 --> 02:58.650
So we can simply uh use this function.

02:58.650 --> 02:59.970
It's called math app.

03:00.770 --> 03:08.330
So we have to use this math f dot f function absolute and then grab it into inside these brackets.

03:08.330 --> 03:14.610
And now it's going to convert minus one into plus one even though we're moving to the left direction.

03:14.610 --> 03:20.490
So if we hold down a key a key then we do know that that movement is going to be minus one.

03:20.490 --> 03:25.970
And this math dot apps function is going to convert that minus one into a plus one.

03:25.970 --> 03:32.290
Now uh, one just going to be greater than zero basically means we just moving to the left or right

03:32.290 --> 03:32.930
direction.

03:33.010 --> 03:38.970
Then what we need to do, we need to set this run parameter to zero and sorry run parameter to one.

03:38.970 --> 03:44.890
And we do know that once we set this run parameter to one it's going to play the running animation clip.

03:44.890 --> 03:48.050
So we have the reference of this animator component.

03:48.050 --> 03:48.850
We do know.

03:48.850 --> 03:50.890
So what we basically gonna do.

03:50.930 --> 03:53.930
Firstly we will move over to animator component.

03:53.930 --> 03:58.570
And we're going to use this dot set float function y this set float function.

03:58.570 --> 04:03.820
Because if we move to unity we can see this run parameter is a float parameter.

04:03.820 --> 04:07.020
So that's why we need to use this animator dot set float.

04:07.060 --> 04:10.140
Basically we just moving over to this animator component.

04:10.180 --> 04:13.020
First of this player game object as you can see.

04:13.060 --> 04:19.100
And after that we just using that set float function in order to set the float of this run parameter.

04:19.620 --> 04:23.820
So as a first argument it's going to take the parameter name in quotation.

04:23.820 --> 04:27.140
So make sure you spell it correct which in my case run.

04:27.180 --> 04:30.020
And the second thing comma it's going to take the value.

04:30.020 --> 04:35.900
So we do know that we're going to set it to one or something like 0.2 which will be greater than 0.1.

04:36.140 --> 04:41.980
And if we set it to something like one, and we do know that if we set it to one, it's going to play

04:41.980 --> 04:43.460
the run animation clip.

04:43.620 --> 04:47.500
And over here we're checking if movement is greater than zero.

04:47.540 --> 04:50.900
F means we start moving to the left or right direction.

04:50.900 --> 04:53.900
In that moment, we need to play the run animation clip.

04:53.940 --> 04:56.860
Basically, we need to set this parameter to one f.

04:56.860 --> 05:00.260
So second thing, it's going to take the value that you want to set.

05:00.260 --> 05:01.940
So we're going to set it to one f.

05:02.060 --> 05:06.100
So firstly we're checking if we're moving to the left or right direction.

05:06.100 --> 05:11.820
If we start moving to the left or right direction then what we're doing firstly we're going to animator

05:11.820 --> 05:16.260
component and we're using this set float function in order to set the float.

05:16.300 --> 05:20.980
Uh, so we're setting this, uh, this one parameter to one, as you can see.

05:21.220 --> 05:27.380
And now if I press down Ctrl s on my keyboard to save my script and then move over to unity, you will

05:27.380 --> 05:34.180
see as soon as beginners start moving to the left or right direction, we will see that this player

05:34.180 --> 05:37.180
GameObject just gonna play the run animation clip.

05:37.180 --> 05:37.660
Why?

05:37.900 --> 05:41.860
Because we're gonna start moving to the left or right direction.

05:42.020 --> 05:46.140
And once we're doing, we're just going over to this animator component.

05:46.140 --> 05:49.420
And by that we're just setting this one parameter to one.

05:49.420 --> 05:54.980
And we do know that once we set, uh, one it's going to play the run animation clip.

05:57.500 --> 05:58.790
So just wait.

06:07.710 --> 06:09.430
So it should work fine.

06:09.430 --> 06:10.830
So just wait a moment.

06:10.830 --> 06:14.350
Once our compilation is done, we can see that.

06:17.470 --> 06:25.070
So we're using that movement parameter in order to set this parameter, uh, that movement variable.

06:25.070 --> 06:28.990
Or you can simply call it parameter as well.

06:29.310 --> 06:30.710
It's basically up to you.

06:30.950 --> 06:34.430
So it's going to take a few second to compile our script.

06:34.630 --> 06:39.190
And once it's done we can just play our game in order to check it.

06:39.430 --> 06:45.630
I really apologize because my system is too much slow, so that's why it's taking a little bit longer

06:45.630 --> 06:47.670
time than as usual.

06:48.070 --> 06:49.990
I really apologize for it.

06:50.750 --> 06:52.430
So just wait.

06:52.590 --> 06:57.150
If you do have a fast system, then in your case, it's gonna turn within.

06:57.190 --> 07:04.030
Uh, something around 10s since my system is slow, so that's why it's taking a little bit longer time.

07:04.230 --> 07:11.070
And now if we click on this play button in the top in order to start our game and try to move left and

07:11.070 --> 07:17.630
right, we do know that that movement is going to be, uh, greater than zero sum with some unit.

07:17.630 --> 07:23.670
It's going to be greater than zero than, uh, we just uh, setting this run parameter to one, as you

07:23.710 --> 07:25.070
seen earlier.

07:25.070 --> 07:31.270
So if I start moving to the left or right direction, as you can see, indeed the run animation is playing

07:31.270 --> 07:33.030
over again and again.

07:33.030 --> 07:36.710
But the problem is that we stuck at run animation clip.

07:36.710 --> 07:40.070
So we also need to set back this run parameter to zero.

07:40.070 --> 07:45.950
But when we shoot, once we stop moving, basically once that movement is going to be zero away.

07:46.070 --> 07:51.870
And we don't know if that movement zero basically means this player just standing at one point, uh,

07:51.870 --> 07:53.950
sorry, standing at one position.

07:53.950 --> 07:57.070
So we need to set back this one parameter to zero.

07:57.070 --> 08:03.920
So if we set manually this run parameter to zero in our animator tab, we can see right away it's now

08:03.920 --> 08:06.120
playing the idle animation clip.

08:06.120 --> 08:08.160
So we need to set it through our code.

08:08.160 --> 08:11.800
So let's get out of play mode and let's move over to our script.

08:11.920 --> 08:15.640
And over here we're going to check else if our movement.

08:15.840 --> 08:25.760
So we will check else if our movement uh main if it is lesser than zero if that is lesser than zero

08:25.760 --> 08:28.720
f or equal to zero f, we can check.

08:28.720 --> 08:35.360
So if it lesser than or equal to zero f, if that is the case, basically means that we are not moving

08:35.360 --> 08:36.040
at all.

08:36.040 --> 08:41.600
And we do know that once we stop moving to the left or right direction, that movement, basically this

08:41.600 --> 08:47.840
movement right over here, uh, it's gonna be zero f or it's it's gonna be zero.

08:47.880 --> 08:54.480
Then over here, we checking else if our movement is lesser than or equal to zero, then what we need

08:54.480 --> 08:57.240
to do, we need to set the that run parameter.

08:57.320 --> 08:59.680
Basically this one back to zero.

08:59.680 --> 09:02.560
So we're going to copy this line of code by Ctrl C.

09:02.760 --> 09:05.480
And let's paste it over here by Ctrl V.

09:05.760 --> 09:09.080
So we need to set this one parameter to zero.

09:09.280 --> 09:11.040
So we're going to set back to zero.

09:11.040 --> 09:15.440
So firstly what we're doing we basically going over to this animator component.

09:15.440 --> 09:20.880
And then we're setting we're using that set float function in order to set this float parameter.

09:20.880 --> 09:24.840
So in our case this run parameter as you can see.

09:24.880 --> 09:29.160
And we're setting it to zero as you can see right over here.

09:29.160 --> 09:35.840
So as a second parameter you need to pass the value and make sure you spell it correct or else it's

09:35.840 --> 09:36.560
not going to work.

09:36.560 --> 09:44.080
So make sure in quotation you put the uh put the spelling correct of that parameter name, else it's

09:44.080 --> 09:44.880
not going to work.

09:44.880 --> 09:52.760
So now if we save our script and then move over to unity and try to stop moving once, uh, once we

09:52.760 --> 10:01.970
start moving and, um, and if we, if we just stop moving, then we will able to notice that run parameter.

10:01.970 --> 10:03.410
We just setting it to zero.

10:03.450 --> 10:04.970
Once we stop moving.

10:05.170 --> 10:10.930
And we do know once we stop moving, that movement is gonna be zero and we're checking if it's zero

10:11.130 --> 10:12.090
or less than zero.

10:12.290 --> 10:15.890
Then we're just setting this run parameter back to zero.

10:15.890 --> 10:21.770
And we do know once we set back to zero, it's going to play the idle animation clip instead of the

10:21.770 --> 10:22.410
running one.

10:22.410 --> 10:28.850
Because if we select from this run back to our idle, we can see in the inspector we have chosen that

10:28.850 --> 10:32.130
condition if our run is less than 0.0.

10:32.490 --> 10:33.890
So 0.1.

10:33.890 --> 10:37.170
So let's click on this play button in the top in order to see.

10:37.450 --> 10:42.690
And we do know that once we start stop moving we just setting run parameter to zero.

10:43.090 --> 10:45.650
And we do know that zero f lesser than 0.1.

10:45.650 --> 10:47.370
So the condition becoming true.

10:47.370 --> 10:50.290
So that's why it's going to play the idle animation clip.

10:50.290 --> 10:57.130
As you can see, as soon as we stop moving we can see we setting back this run parameter to zero eight

10:57.130 --> 11:03.570
via our code, but once we start moving, we just setting this one parameter to one, as you can see.

11:03.690 --> 11:10.690
And as soon as we stop moving, we just set it back this one parameter to zero so we can see the condition

11:10.690 --> 11:11.970
it's becoming true.

11:11.970 --> 11:18.450
So that's why the idle animation clip of this player game object is now playing over again and again.

11:18.730 --> 11:23.530
But once we jump, we not playing our jump animation clip at all.

11:23.530 --> 11:25.610
So let's make that one as well.

11:25.650 --> 11:30.970
Basically we need to set this jump parameter to true this jump parameter right over here.

11:30.970 --> 11:32.450
So let's get out of play mode.

11:32.450 --> 11:36.050
And we do know we have the reference of this animator component.

11:36.050 --> 11:37.130
So let's do it.

11:37.130 --> 11:42.130
So let's go over to our script and let's move over to jump function where we're jumping.

11:42.130 --> 11:44.770
So as you can see we're jumping over here.

11:44.770 --> 11:50.330
So this jump function we calling once we press down space key basically we jumping.

11:50.330 --> 11:55.530
So in that moment what we need to do we basically need to set this jump parameter to true.

11:56.090 --> 11:57.770
So we will do that.

11:57.770 --> 11:59.690
So over here we jumping.

11:59.690 --> 12:00.770
So what we will do.

12:00.810 --> 12:03.810
Firstly we will go to animator animator.

12:03.810 --> 12:07.490
And now we're going to use this dot set bool function.

12:07.530 --> 12:08.650
Set bool function.

12:08.650 --> 12:12.690
And let's make this first packet why we using this set bool function.

12:12.690 --> 12:18.290
Because if we move over to unity editor we can see this jump parameter is a bool parameter.

12:18.290 --> 12:21.410
So that's why we need to use a instead of set float.

12:21.410 --> 12:23.610
We need to use this set bool function.

12:23.610 --> 12:28.650
And now this function in quotation as a first argument it's gonna take the parameter name.

12:28.650 --> 12:33.050
So in our case jump and make sure you spell it correct as well.

12:33.050 --> 12:37.490
That one which is jump in our case uh, our case.

12:37.490 --> 12:41.690
And the second thing it's going to take the value which can be true or false.

12:41.690 --> 12:47.770
So if we set it to true it's going to play the jump animation clip basically means we're checking that

12:47.930 --> 12:50.210
uh checking that means we're setting it to true.

12:50.410 --> 12:53.770
So we're going to set it to true since we're jumping over here.

12:53.770 --> 12:56.220
So as a second argument we're going to pass through.

12:56.260 --> 12:58.380
And let's close that up with semicolon.

12:58.380 --> 13:01.420
And now we're going to press down Ctrl S to save our script.

13:01.420 --> 13:03.380
And now let's move over to unity.

13:03.380 --> 13:09.060
So whenever we're going to press down space key on our keyboard then we're calling this jump function.

13:09.060 --> 13:10.100
And we're jumping.

13:10.100 --> 13:13.980
And after jumping also we're just going over to animator component.

13:13.980 --> 13:20.100
And then we're using the set bool function in order to set that bool parameter in our case that jump

13:20.100 --> 13:21.740
parameter in quotation.

13:21.740 --> 13:28.580
So now if we just go ahead and then click on this play button in the top in order to play our game and

13:28.580 --> 13:34.660
try to press down space key on our keyboard, we will be able to notice that we're gonna, uh, we're

13:34.660 --> 13:36.580
gonna play the jump animation clip.

13:36.580 --> 13:42.180
So now if I press down space key on my keyboard, as you can see, as soon as we press down space Key,

13:42.260 --> 13:44.420
it's played the jump animation clip.

13:44.420 --> 13:48.140
But the problem is that we stuck in jump animation clip.

13:48.140 --> 13:51.580
So we also need to set back this jump parameter to false.

13:51.580 --> 13:57.980
So if we set it manually to false, as you can see it's now playing the idle animation clip, so when

13:57.980 --> 14:02.900
we need to set it to false, once this player game object is just going to collide with this prompt,

14:02.940 --> 14:05.620
then we're going to uh, then we will do it.

14:05.620 --> 14:07.260
So let's get out of play mode.

14:07.260 --> 14:11.020
And for that we're going to use Oncollisionenter 2D function.

14:11.020 --> 14:17.660
So let's go over to script and let's make it somewhere over here and make sure you're just doing as

14:17.660 --> 14:21.460
I did over here which is on collision enter 2D function.

14:21.460 --> 14:25.020
So this function get called when we collide with something we do know.

14:25.020 --> 14:30.900
And we can extract information what we collided with by going over to this collision parameter.

14:30.900 --> 14:32.780
So what we're going to do over here.

14:32.780 --> 14:35.620
So this function get called when we collide with something.

14:35.620 --> 14:38.820
So let's suppose this player GameObject collide with this ground.

14:38.860 --> 14:41.420
Then this function over here just going to get called.

14:41.420 --> 14:47.220
And we can extract information about what we collided with with this collision parameter.

14:47.220 --> 14:52.340
So what we will do if we select our ground in the hierarchy then go over to Inspector.

14:52.340 --> 14:55.190
We can see tag and we we just is untagged.

14:55.230 --> 14:57.910
So let's assign this ground as a ground tag.

14:57.950 --> 15:00.550
So firstly select your ground in the hierarchy.

15:00.590 --> 15:02.510
Go over to Inspector and Tag.

15:02.550 --> 15:04.470
As you can see it says untagged.

15:04.510 --> 15:07.470
So just click there and then click on this add tag.

15:07.510 --> 15:11.390
Then click on this plus icon and in the tag whatever you want.

15:11.470 --> 15:16.990
So I'm gonna create a ground tag and I'm gonna assign this ground as a ground tag.

15:17.030 --> 15:18.790
So let's call it ground.

15:18.790 --> 15:24.470
And let's click on the save button and make sure you select your game object one more time in the hierarchy.

15:24.710 --> 15:28.110
And if we move over to Inspector we can see tag.

15:28.150 --> 15:29.510
And it says untagged.

15:29.630 --> 15:32.990
So we're gonna assign with ground as we created recently.

15:33.030 --> 15:35.670
Now we assign it this ground as a ground tag.

15:35.710 --> 15:37.710
As you can see in Inspector.

15:37.910 --> 15:40.790
So now we assign it this ground as a ground tag.

15:40.790 --> 15:44.030
And what we will do now and over here we're going to check.

15:44.030 --> 15:47.030
So this function get called when we collide with something.

15:47.030 --> 15:49.630
And we will, we will check before we collide.

15:49.630 --> 15:51.270
So let's use this if condition.

15:51.270 --> 15:53.830
Let's make first bracket and some curly brackets.

15:54.150 --> 15:55.950
So what we want to check over here.

15:55.950 --> 15:59.190
We basically want to check whatever we collided with.

15:59.230 --> 16:01.790
If that game object has a tag called ground.

16:01.790 --> 16:07.070
So we definitely gonna collide with this ground game object and we assign it this ground as a ground

16:07.070 --> 16:07.270
tag.

16:07.310 --> 16:09.310
As you can see in the inspector.

16:09.310 --> 16:10.830
So means that we colliding.

16:10.830 --> 16:14.910
So what we need to do, we need to set back this jump parameter to false.

16:14.910 --> 16:20.390
And we do know that if we set it to false means uncheck it's gonna play the idle animation clip.

16:20.390 --> 16:25.590
But before we do, let's print out a message if we're colliding with this ground or not.

16:25.590 --> 16:27.350
So let's go over to our script.

16:27.510 --> 16:29.830
Over here we will use this collision.

16:29.830 --> 16:33.310
So collision dot GameObject dot tag.

16:33.470 --> 16:36.590
If if the tag is equals equals to ground.

16:36.590 --> 16:39.470
So in quotation we're going to pass this ground.

16:40.430 --> 16:46.310
So what we're doing right over here we basically just going over to collision dot GameObject dot tag.

16:46.350 --> 16:51.150
So collision dot GameObject over here basically means the GameObject we collided with.

16:51.150 --> 16:54.110
So this player GameObject just collide with this ground.

16:54.200 --> 16:58.080
So Collision's GameObject right over here basically means this ground.

16:58.080 --> 17:03.080
And after that what we're doing, we're just accessing the tag of it of that GameObject.

17:03.080 --> 17:06.360
And we're checking if the tag is equals equals to ground.

17:06.360 --> 17:07.400
As you can see.

17:07.440 --> 17:13.280
And we do know that we assign it this ground as a ground tag as we can notice in the inspector.

17:13.400 --> 17:16.320
So we definitely gonna collide with this ground.

17:16.320 --> 17:17.760
So now what we have to do.

17:17.840 --> 17:20.720
We need to set back this parameter to false.

17:20.720 --> 17:23.280
But before we set let's print out a message.

17:23.280 --> 17:28.840
If we collide it with that crown or not for printing out, we're gonna type this debug.log.

17:28.840 --> 17:34.640
And let's say something like we player let's say player collided.

17:34.880 --> 17:38.000
Collided with a crown.

17:38.000 --> 17:40.440
Something like that crown.

17:40.440 --> 17:45.600
And let's close that open semicolon and we're gonna press down Ctrl s to save our skin.

17:45.600 --> 17:47.600
And now let's move over to unity.

17:47.600 --> 17:53.200
So as soon as this player GameObject just collide with this crown, you will see that message just gonna

17:53.200 --> 17:56.360
pop up says a player collided with ground.

17:56.360 --> 18:01.160
Because we just printing out that message as soon as we're gonna collide with this ground.

18:01.360 --> 18:05.880
So let's select our console tab and let's click on this play button in the top.

18:05.880 --> 18:11.640
But before you do, make sure you assign your ground as a ground tag by going over to Inspector.

18:11.680 --> 18:15.320
As I, uh, as I explained earlier.

18:17.360 --> 18:23.760
So now, as you can see, as soon as we collided with this ground, we can see the message in the console

18:23.800 --> 18:30.200
tab just printing out says player collided with the ground instead of printing out message what we basically

18:30.200 --> 18:30.800
want to do.

18:30.840 --> 18:33.600
We basically need to set this parameter to false.

18:33.600 --> 18:38.360
Basically uncheck and we can see if we set that to unchecked means false.

18:38.400 --> 18:40.720
It's going to play the idle animation clip.

18:40.720 --> 18:46.120
And if the player is moving left and right, then it's going to play the run animation clip instead

18:46.120 --> 18:47.160
of the idle.

18:47.160 --> 18:50.120
So let's get out of play mode and let's set it.

18:50.120 --> 18:54.250
So instead of printing out message, we're going to set back that animator.

18:54.490 --> 18:56.970
Uh, sorry, that jump parameter to false.

18:56.970 --> 19:01.250
So let's double click on this message in order to move over to that line of code.

19:01.290 --> 19:05.850
Instead of doing this, we're going to move over to our animator component.

19:05.850 --> 19:08.610
And now we're going to use this dot set bool function.

19:08.810 --> 19:14.610
And first thing it's going to take in quotation the bool name, which in our case jump and make sure

19:14.610 --> 19:15.890
you spelling it correct.

19:15.890 --> 19:18.130
And the second thing it's going to take the value.

19:18.130 --> 19:19.490
So we're going to set it to false.

19:19.490 --> 19:24.330
Basically means unchecked means that we're going to play the idle animation clip.

19:24.330 --> 19:30.570
If the player just standing at one point and if the player is moving, then it's going to play the running

19:30.570 --> 19:31.650
animation clip.

19:31.650 --> 19:34.530
So now we're going to press down Ctrl S to save our script.

19:34.530 --> 19:36.650
And now let's move over to unity.

19:36.650 --> 19:42.450
So as soon as we're going to collide with this ground we will able to notice, uh, this player just

19:42.450 --> 19:48.810
gonna play the idle or the run animation clip, depending upon what player is really doing.

19:48.850 --> 19:53.570
If the player is moving left and right, then it's going to play the running animation clip.

19:53.570 --> 19:57.810
So let's click on this play button in the top in order to play our game.

19:57.850 --> 19:59.610
And let's take a look on this.

19:59.970 --> 20:05.370
So we're not gonna stack in jump animation clip by now forever.

20:05.370 --> 20:07.210
We're not gonna stack forever.

20:07.210 --> 20:13.450
So if I pressed on space key on my keyboard, as you can see, it's playing idle animation clip as soon

20:13.450 --> 20:16.730
as this player GameObject colliding with this ground.

20:16.730 --> 20:22.210
Because once we colliding with this ground, firstly we're checking the tag if that game object has

20:22.250 --> 20:27.730
a ground tag, and we definitely can see that we assign it this ground as a ground tag.

20:27.770 --> 20:30.770
Then we're just setting that jump parameter to false.

20:30.770 --> 20:37.330
And if we start moving, it's played right away the running animation clip instead of the idle, as

20:37.330 --> 20:38.090
you can see.

20:38.210 --> 20:45.970
But if we stop moving, then in this moment we're just playing this idle animation clip, since we have

20:45.970 --> 20:52.450
done all of those things, as you can see right over here, back to run and then idle.

20:52.450 --> 20:54.060
Idol, so I hope you get the idea.

20:54.060 --> 20:55.740
So I'm going to get out of play mode.

20:55.900 --> 20:57.540
So firstly, what are we doing?

20:57.580 --> 21:00.860
Firstly we just grabbing the animator component reference.

21:00.860 --> 21:04.540
So firstly you need to make sure that you grab the reference first.

21:04.540 --> 21:06.980
And we're doing inside this start function.

21:06.980 --> 21:13.900
If I, if I move over to uh top of my class, as you can see in the start function, I'm just taking

21:13.900 --> 21:19.740
that animator component of that player game object, and we will be storing that into this animator.

21:19.740 --> 21:26.540
And after grabbing the reference, we just are setting those run and then jump parameter depending upon

21:26.540 --> 21:28.620
what player is really doing.

21:28.820 --> 21:33.940
So we also need to trigger this parameter which is attack one, attack two and attack three.

21:33.940 --> 21:37.340
And we're going to take a look on this next lecture.

21:37.340 --> 21:40.900
We're going to take a look on on this uh sorry.

21:40.940 --> 21:44.260
We're going to take a look on this in the next lecture.

21:44.260 --> 21:48.180
So I hope you get the idea that how you can do it via scripting.

21:48.220 --> 21:53.220
And I'm going to press control S on my keyboard in order to save my project.
