WEBVTT

00:00.040 --> 00:02.720
Now we need to make animation transition.

00:02.720 --> 00:08.480
So if I select my player GameObject in the hierarchy and then move over to animator tab, as you can

00:08.480 --> 00:13.280
see, we have uh, we are already created multiple animation clip.

00:13.320 --> 00:17.360
We have player run, player jump, player attack and all of these.

00:17.720 --> 00:23.680
So if you're not able to find the animator tab then go to window in the top, then animation in the

00:23.680 --> 00:26.960
bottom and then animator tab and you're gonna get it.

00:26.960 --> 00:31.320
So we have this animation clip and I'm gonna drag it up.

00:31.320 --> 00:34.920
So we need to make transition between this animation clip.

00:35.320 --> 00:41.720
So before I do and then click on this play button in the top, you will see uh right after the game

00:41.720 --> 00:44.840
start this player idle animation just gonna play.

00:44.880 --> 00:45.400
Why?

00:45.440 --> 00:47.800
Because that one is the default one.

00:47.800 --> 00:52.000
And let's suppose you want another animation clip to be default one.

00:52.040 --> 00:53.920
Then you have to do something else.

00:53.960 --> 01:00.520
As you can see, as soon as our game started, we can see this player just playing the player idle animation

01:00.640 --> 01:02.520
clip over again and again.

01:02.840 --> 01:07.480
And so let's suppose you want this animation clip which is player underscore run.

01:07.520 --> 01:11.080
Then right click on it and then set as layer default state.

01:11.080 --> 01:18.840
And as soon as we set we can see this player run is now the is now basically the default state by it.

01:18.960 --> 01:20.880
I want to live with this player idle.

01:20.880 --> 01:27.600
So I'm gonna set that player set as default state and I'm gonna get out of play mode.

01:27.600 --> 01:33.880
So we need to make transition between this animation clip from this player idle to player run, player

01:33.920 --> 01:39.960
jump, player attack one, attack two, attack three, and all of these to do so, what we basically

01:39.960 --> 01:46.440
have to do, we need to right click on this player idle Animation clip and then click on this make transition.

01:46.440 --> 01:48.920
And let's make transition to this player run.

01:49.400 --> 01:54.400
And now if we select this transition or this arrow and then go over to Inspector.

01:54.440 --> 01:57.240
As you can see it says has exit time.

01:57.240 --> 02:03.190
So we're gonna uncheck this because we're gonna make the transition right away and transition duration,

02:03.190 --> 02:04.670
we're going to set it to zero.

02:04.670 --> 02:11.070
And if we scroll down, we need to choose a condition in which condition we want to play that animation

02:11.070 --> 02:11.590
clip.

02:11.590 --> 02:16.990
So we need to set some certain condition in order to play this animation clip.

02:16.990 --> 02:21.030
So in animator tab we can see layers and then these parameters.

02:21.030 --> 02:22.910
So let's click on this plus icon.

02:22.910 --> 02:25.230
And I'm going to choose a float parameter.

02:25.390 --> 02:28.470
And we can call this parameter whatever you like.

02:28.470 --> 02:30.590
So let's call it something like run.

02:30.790 --> 02:33.550
And now we're going to choose this condition if run.

02:33.550 --> 02:38.710
So to choose this condition go over to Inspector and make sure you select that transition.

02:38.710 --> 02:44.470
Go over to Inspector and then click on scroll down to the bottom and then click on this plus icon.

02:44.470 --> 02:45.950
And we will choose that.

02:45.990 --> 02:53.430
If run is greater than and we're going to check with smaller number something like 0.01 or or we can

02:53.430 --> 02:55.870
check with .0.1.

02:55.910 --> 02:58.710
So with some smaller number something like 0.1.

02:59.150 --> 03:07.630
So if our run parameter is greater than 0.1, then we want to play this player run animation clip.

03:07.750 --> 03:11.150
Because as you can see we have chosen that condition.

03:11.190 --> 03:15.630
So we have chosen that if run parameter is greater than 0.1.

03:15.630 --> 03:18.910
So let's suppose we set this one to something like one.

03:18.910 --> 03:24.590
And one will be definitely just gonna be definitely gonna be greater than point one.

03:24.590 --> 03:26.750
So the condition is becoming true.

03:26.750 --> 03:30.830
So that's why this player run animation gonna play and let me show you.

03:30.830 --> 03:36.470
So if I just go ahead and then click on this play button and then manually set this run parameter to

03:36.510 --> 03:38.990
something like 0.2 or 1.

03:39.350 --> 03:42.350
And then it's going to play the player run animation clip.

03:42.390 --> 03:42.870
Why?

03:43.030 --> 03:50.030
Because if we set it to one, so run one so one, we do know that it's it's just going to be greater

03:50.030 --> 03:51.150
than point one.

03:51.470 --> 03:57.910
So if I set this run parameter to one inch my animator tab, as you can see, as soon as we have chosen

03:57.910 --> 03:59.790
one it's playing the player.

03:59.790 --> 04:01.710
Underscore run animation clip.

04:01.750 --> 04:02.270
Why?

04:02.510 --> 04:07.190
Because we set this run one and one is greater than 0.1.

04:07.190 --> 04:09.470
So the condition is becoming true.

04:09.470 --> 04:11.910
So that's why this animation is playing.

04:12.230 --> 04:17.590
And if we set back to zero it's not playing at all the idle animation clip.

04:17.630 --> 04:19.030
Uh, why?

04:19.070 --> 04:22.510
Because we also need to make transition back to our idle.

04:22.670 --> 04:24.950
So to do that, let's get out of play mode.

04:24.950 --> 04:30.390
And let's right click on this player underscore run and then make transition back to player idle.

04:30.390 --> 04:34.350
And we're going to choose this transition or this condition.

04:34.350 --> 04:35.910
Then go over to Inspector.

04:35.910 --> 04:36.950
And we're gonna untick.

04:36.950 --> 04:41.710
This has exit time because we want to play the player idle animation clip.

04:41.750 --> 04:47.790
As soon as they as soon as this player stops running or stops moving.

04:47.990 --> 04:50.910
And also let's set the transition duration to zero.

04:50.910 --> 04:54.430
And if we scroll down and we need to choose a condition.

04:54.430 --> 04:58.190
So we're gonna choose the same condition with a different state.

04:58.190 --> 05:00.670
So basically we're going to click on this plus icon.

05:00.670 --> 05:07.750
And now we're going to choose if run is lesser than with a smaller number something like 0.1 as we have

05:07.750 --> 05:10.750
done from this player idol to player run.

05:10.910 --> 05:17.310
So if we set this player run to zero, and we do know that if we set this run parameter to zero and

05:17.310 --> 05:19.390
zero will be lesser than 0.1.

05:19.390 --> 05:21.950
So the condition is becoming true.

05:22.150 --> 05:26.630
And let's suppose we set this run parameter to something like minus one.

05:26.790 --> 05:33.870
And minus one will definitely gonna be lesser than 0.1, because minus one is lesser than 0.1.

05:33.870 --> 05:37.230
So the condition is becoming true.

05:37.630 --> 05:40.750
So that's why it's gonna play the idle animation clip.

05:40.750 --> 05:45.990
Or else we can set this parameter to zero and zero will be lesser than 0.1.

05:46.030 --> 05:46.830
We do know.

05:46.830 --> 05:48.870
So the condition is becoming true.

05:48.870 --> 05:54.070
So that's why this player idle animation gonna play instead of the run.

05:54.070 --> 05:57.230
Once we set back this run parameter to zero.

05:57.270 --> 05:58.310
Let me show you.

05:58.310 --> 06:02.340
So let's click on this play button in the top in order to start our game.

06:02.340 --> 06:04.140
And let's check it one more time.

06:04.300 --> 06:09.420
So if we set this one parameter to one, then it's gonna play the run animation clip.

06:09.620 --> 06:16.060
And if we set this run parameter to back to zero it's gonna play the idle animation clip.

06:16.060 --> 06:22.580
So if I set this run parameter to one, as you can see, as soon as we have set this one parameter to

06:22.620 --> 06:25.820
one, it's playing the player underscore run animation clip.

06:25.820 --> 06:26.180
Why?

06:26.500 --> 06:31.300
Because if we set this run to one and one will be greater than 0.1.

06:31.300 --> 06:33.220
So the condition is becoming true.

06:33.220 --> 06:37.020
So that's why this player underscore run animation is playing.

06:37.260 --> 06:41.220
And if we set this manually this run parameter to zero.

06:41.380 --> 06:46.980
As you can see as soon as we have chosen zero it's playing the player idle animation clip.

06:46.980 --> 06:47.380
Why.

06:47.540 --> 06:51.180
If we choose the back transition then go over to Inspector.

06:51.220 --> 06:53.820
We can see if we set this run to zero.

06:53.820 --> 06:56.260
So zero will be less than 0.1.

06:56.260 --> 06:58.540
So the the condition becoming true.

06:58.540 --> 07:02.220
So that is the main reason it's playing the player.

07:02.620 --> 07:04.700
Underscore idle animation clip.

07:04.900 --> 07:08.620
So basically we need to set this one parameter through our code.

07:08.660 --> 07:13.140
Basically once we start moving then we're going to set this parameter to one.

07:13.140 --> 07:15.620
So it will play the run animation clip.

07:15.820 --> 07:19.980
And once we're gonna set back this run parameter to zero through our code.

07:20.020 --> 07:24.860
Basically once we stop moving then we're gonna set this run parameter to zero.

07:24.860 --> 07:28.980
So it will play the player underscore idle animation clip.

07:28.980 --> 07:30.700
So let's get out of play mode.

07:30.700 --> 07:39.060
And also let's make transition from this player idle uh, to this player jump basically from any transition.

07:39.060 --> 07:43.820
We want to make the jump no matter what state we are in.

07:43.860 --> 07:50.900
Let's suppose this player, a player is running, and then we simply press down space key on our keyboard.

07:50.940 --> 07:57.620
Then we want to play the jump animation right away, no matter if this player is running or standing

07:57.700 --> 07:58.740
at one point.

07:58.740 --> 08:02.100
So we want to play the player jump animation clip right away.

08:02.140 --> 08:03.780
No matter what we're doing.

08:03.780 --> 08:07.220
So that's why we're going to make transition from this anime state.

08:07.220 --> 08:11.580
So we will right click on this any state, then make transition to player jump.

08:11.740 --> 08:13.900
And let's choose this transition.

08:13.900 --> 08:16.780
Let's go over to Inspector and we're gonna untick.

08:16.780 --> 08:23.580
This has exit time as well as we will set the fixed duration uh the transition duration to zero.

08:23.740 --> 08:27.860
And if we scroll down we need to choose a condition in which condition?

08:27.860 --> 08:30.340
We want to play that animation clip.

08:30.660 --> 08:37.420
So we're gonna choose a second condition or a parameter for, uh, for in order to make our player jump

08:37.420 --> 08:38.500
animation clip.

08:38.540 --> 08:40.860
To do so let's click on this plus icon.

08:40.860 --> 08:44.700
And now we're gonna choose a bool parameter which can be true or false.

08:44.700 --> 08:47.060
And let's call this one something like jump.

08:47.660 --> 08:51.660
And sorry to rename this you can just double click on it.

08:51.820 --> 08:53.740
And we're going to call this jump.

08:53.740 --> 08:55.820
And we want to choose this condition.

08:55.820 --> 08:59.420
So let's go over to Inspector and let's click on this plus icon.

08:59.420 --> 09:01.580
And we're gonna choose this jump parameter.

09:01.580 --> 09:05.180
So we will set if if jump parameter is true.

09:05.220 --> 09:09.900
Basically if we check it check basically means that we just setting it to true.

09:10.020 --> 09:12.820
It's going to play the player jump animation clip.

09:12.820 --> 09:13.780
So let me show you.

09:13.780 --> 09:18.620
So let's click on this play button in the top uh top to play our game.

09:18.620 --> 09:22.780
And if we set this jump parameter manually to true basically means check.

09:22.820 --> 09:25.180
You will see this player jump animation.

09:25.180 --> 09:28.860
Just gonna play right away right away.

09:29.300 --> 09:31.220
So let's have a look on it.

09:31.220 --> 09:35.140
So if I check this one parameter sorry this jump parameter to check.

09:35.140 --> 09:35.980
Basically true.

09:36.020 --> 09:38.020
Uh, we just setting it to true.

09:38.220 --> 09:43.660
As you can see, as soon as we just setting it to true it's played the player jump.

09:43.700 --> 09:48.180
But the but the problem is that we stuck at jump animation clip.

09:48.180 --> 09:52.460
So we also need to go back to player idle as well as player run.

09:52.500 --> 09:58.090
Depending upon what player is doing, it's uh, if the player is running.

09:58.370 --> 09:59.570
Uh, sorry.

09:59.650 --> 10:02.770
If the player is moving to the left or right direction.

10:02.770 --> 10:07.010
So in that moment, we need to make transition from this player jump to player run.

10:07.130 --> 10:13.410
And if the player stops moving, then in that moment we need to play the player ideal instead of the

10:13.410 --> 10:14.250
player run.

10:14.250 --> 10:16.010
So let's get out of play mode.

10:16.010 --> 10:20.370
So from this player jump we also gonna make a two player ideal.

10:20.370 --> 10:21.850
So let's right click on it.

10:22.130 --> 10:26.090
Player jump animation clip and make transition to player ideal.

10:26.370 --> 10:28.490
And let's choose this transition.

10:28.730 --> 10:30.610
And we will go over to Inspector.

10:30.610 --> 10:33.330
And we will uncheck the has exit time.

10:33.330 --> 10:42.530
Because as soon as we touch our crown or uh ground or you can simply say ground, then we want to play

10:42.530 --> 10:45.330
the idle animation clip right away.

10:45.330 --> 10:48.090
So that's why we just uncheck has exit time.

10:48.090 --> 10:50.970
Also let's say this transition duration to zero.

10:50.970 --> 10:54.450
And if we scroll down we need to choose the condition.

10:54.450 --> 10:55.970
So we're gonna choose that condition.

10:55.970 --> 10:57.810
So let's click on this plus icon.

10:57.810 --> 11:00.010
Firstly we're going to choose if jump.

11:00.010 --> 11:02.690
So we're going to set this jump parameter to false.

11:02.690 --> 11:09.450
Basically if we uncheck this jump parameter to uncheck this jump parameter basically means we set it

11:09.450 --> 11:10.130
to false.

11:10.330 --> 11:13.370
Then it's going to play the player idle animation clip.

11:13.370 --> 11:17.130
And we can choose a second condition as well which is the run.

11:17.130 --> 11:20.850
So we're going to choose if run is less than 0.1.

11:20.890 --> 11:21.970
If that is the case.

11:21.970 --> 11:27.210
And we do know that once it's less than 0.1 basically means we stop smoking.

11:27.210 --> 11:30.690
So in that moment we're going to play the idle animation clip.

11:30.690 --> 11:35.970
And we do know that once we stop moving, we're gonna set this parameter to zero.

11:35.970 --> 11:38.330
And zero will be less than 0.1.

11:38.330 --> 11:40.370
So the condition is becoming true.

11:40.370 --> 11:47.730
And also if we set this parameter to false basically uncheck you will see this idle animation just gonna

11:47.730 --> 11:50.010
play instead of this running one.

11:50.010 --> 11:54.130
So we also need to make transition from this player jump to player run.

11:54.170 --> 11:58.690
If the player is moving to the right or left direction.

11:58.690 --> 12:01.890
So let's right click on this player underscore jump.

12:01.890 --> 12:05.250
And let's make a let's make transition to player run.

12:05.450 --> 12:07.250
And let's select this transition.

12:07.250 --> 12:08.810
Let's go over to Inspector.

12:08.810 --> 12:10.930
And we're going to uncheck has exit time.

12:10.930 --> 12:14.010
And also let's set the transition duration to zero.

12:14.010 --> 12:15.370
And let's scroll down.

12:15.370 --> 12:17.530
So we need to choose a condition.

12:17.530 --> 12:18.890
So we're going to choose two condition.

12:18.890 --> 12:22.930
So first condition we will choose if jump parameter is false.

12:23.130 --> 12:24.370
If that is the case.

12:24.370 --> 12:28.570
And the second parameter we're going to choose if run is greater than 0.1.

12:29.170 --> 12:35.130
If that is the case means if we set this parameter to one so one will be greater than 0.1.

12:35.130 --> 12:42.130
So we do know that it's it's going to play the run animation clip instead of the idle as soon as we

12:42.170 --> 12:43.610
touches our ground.

12:43.610 --> 12:44.530
So let me show you.

12:44.530 --> 12:47.330
So let's click on this play button in the top.

12:47.530 --> 12:54.210
And if we set this jump parameter to manually check or uncheck basically true or false, you will see

12:54.210 --> 12:56.130
it's gonna play the run up.

12:56.650 --> 12:57.050
Sorry.

12:57.090 --> 13:03.730
It's gonna play the idle animation or run animation clip depending upon what player is really doing.

13:03.810 --> 13:07.050
So if I check this one parameter to true, basically.

13:07.210 --> 13:08.450
Uh, true.

13:08.610 --> 13:11.090
As you can see, it's played the jump.

13:11.210 --> 13:17.530
And if I uncheck it, we can see it's played the player idle instead of the player run.

13:17.570 --> 13:17.930
Why?

13:17.970 --> 13:21.010
Because this player is not moving at all.

13:21.010 --> 13:21.810
So that's why.

13:21.970 --> 13:25.810
And we're gonna set this, uh, parameters through our code.

13:25.970 --> 13:30.410
And I'm doing manually to just explain this.

13:30.410 --> 13:36.890
So let's get out of play mode, and let's also make transition to this player attack player attack two

13:36.930 --> 13:38.650
and player attack three.

13:38.650 --> 13:40.050
And we're gonna make transition.

13:40.050 --> 13:45.810
Once our player stops moving, basically a player is standing at one point.

13:45.850 --> 13:48.290
Then we want to play this animation clip.

13:48.490 --> 13:52.570
If the player is moving or jumping then we don't want to play this.

13:52.610 --> 13:54.930
Attack three, attack two or attack one.

13:55.000 --> 13:56.920
animation clip of this player.

13:57.240 --> 14:04.480
So we all only want to make transition from this player idle if the player just standing at one point.

14:05.280 --> 14:07.400
I really apologize for the noises.

14:07.880 --> 14:14.400
Uh, so what we're gonna do, we're gonna make transition from, uh, from this player idle to player

14:14.400 --> 14:17.560
attack one, attack two, and this attack three.

14:17.920 --> 14:19.400
So let's make transition.

14:19.400 --> 14:22.280
So let's right click on this, uh, player idle.

14:22.400 --> 14:25.120
And let's make transition to player attack one.

14:25.120 --> 14:27.080
And let's choose this transition.

14:27.280 --> 14:30.320
Let's go over to Inspector and we're gonna untick.

14:30.320 --> 14:34.680
This has exit time and transition uh fixed duration.

14:35.440 --> 14:39.840
We're gonna uncheck or we can just leave it and transition duration.

14:39.840 --> 14:41.600
We can set it to zero.

14:41.880 --> 14:47.600
And if we scroll down, we need to choose a condition in which condition we want to play this attack

14:47.600 --> 14:49.080
one animation clip.

14:49.560 --> 14:55.840
So what we're gonna do, let's take a look in the next lecture of it.
