WEBVTT

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

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

00:01.490 --> 00:06.950
In this one I want to show you how to work with a blend tree and how blend tree can be useful in the

00:06.950 --> 00:08.090
animator at all.

00:08.090 --> 00:11.210
So first let's create a blend tree and see what it does.

00:11.210 --> 00:13.160
We're going to click create button over here.

00:13.160 --> 00:16.070
Create state from New Blend Tree.

00:16.070 --> 00:21.410
Now let's select it and name it as Idle Slash Move.

00:22.470 --> 00:27.810
And inside you can select the blend tree and you can add a bunch of motions.

00:27.810 --> 00:30.090
Here I'm going to click add motion.

00:30.420 --> 00:31.470
Add motion.

00:31.500 --> 00:32.550
Add motion.

00:34.030 --> 00:35.710
Now let's select.

00:36.430 --> 00:37.630
Player move.

00:38.250 --> 00:42.090
Layer idol and layer move.

00:42.570 --> 00:50.790
We can open preview over here and if we click play button you can see animation being played.

00:50.850 --> 00:54.000
Now let's uncheck Automate threshold over here.

00:58.860 --> 01:01.560
And let's do minus one.

01:02.590 --> 01:04.780
Zero one.

01:05.310 --> 01:10.710
Now this threshold will control transition between animations by itself.

01:10.890 --> 01:17.460
So if we have value at zero, then player will stand in the idle animation.

01:17.460 --> 01:20.610
If we move value to the left to the negative value.

01:20.640 --> 01:26.040
You can see player is in the running animation if we go back to zero.

01:27.830 --> 01:29.630
He stands in the idol.

01:29.630 --> 01:33.470
If we increase the value, he goes to the running animation again.

01:35.690 --> 01:43.880
And this can be used to control idle and move animation instead of these two animations with the transitions.

01:43.910 --> 01:46.400
All right, let's just go inside.

01:47.110 --> 01:50.470
And we need to rename this parameter over here.

01:50.470 --> 01:53.380
I'm going to name it as x velocity.

01:54.320 --> 01:57.680
And then we need to be sure this parameter is selected over here.

02:01.270 --> 02:02.320
X velocity.

02:02.350 --> 02:05.380
Now let's go back to base layer.

02:05.380 --> 02:06.910
We can delete these two.

02:06.940 --> 02:09.490
I just wanted to show you an example on how it could work.

02:09.490 --> 02:10.930
But don't be sorry.

02:10.930 --> 02:12.160
Just remove them.

02:12.220 --> 02:17.770
And this blend tree will become a default state animation of the player.

02:17.800 --> 02:25.030
We can delete this parameter as well, and we can only update this animation by updating info on the

02:25.030 --> 02:26.170
x velocity.

02:26.170 --> 02:30.130
And that would do the entire job for us with the transitions.

02:30.130 --> 02:31.420
Very convenient way.

02:31.420 --> 02:32.680
Very clean I think.

02:32.680 --> 02:33.640
Very efficient.

02:33.880 --> 02:35.980
So let's go to player script.

02:37.010 --> 02:41.780
And over here, instead of setting boolean, we can just type.

02:42.610 --> 02:46.690
Einem said float of the x velocity.

02:46.690 --> 02:48.820
And again I'm scared I'll make a mistake.

02:48.820 --> 02:50.920
So I'll go here.

02:50.920 --> 02:57.010
I'll copy this, go back to script, paste this in, and then as a value that we want to have for that

02:57.010 --> 03:00.220
parameter we're going to pass rb velocity dot x.

03:00.730 --> 03:01.630
And that's it.

03:02.140 --> 03:03.610
Simple as that.

03:03.700 --> 03:07.480
Now let's save this and go back to unity.

03:08.530 --> 03:10.510
And see if it's working.

03:13.510 --> 03:14.320
Idol.

03:14.890 --> 03:15.760
Move.

03:17.400 --> 03:19.200
Mauve idol.

03:19.410 --> 03:20.550
Very cool.

03:20.550 --> 03:21.690
Love it so much, man.

03:21.720 --> 03:22.770
Really nice.

03:23.130 --> 03:27.510
Um, I can see there is a bit of a jittering effect when we move in.

03:27.510 --> 03:30.660
You can see on the character he sort of jittering.

03:31.920 --> 03:34.470
To fix that, we can go to the rigid body.

03:35.820 --> 03:39.570
And go to interpolate and choose interpolate.

03:39.900 --> 03:43.320
Now when we move, it's going to feel smooth and nice.

03:43.860 --> 03:45.990
It has to do with the update of a physics.

03:45.990 --> 03:47.910
It's not that important right now.

03:51.470 --> 03:52.340
All right.

03:52.580 --> 03:53.690
Very good.

03:53.690 --> 03:56.030
Oh, we need to do this out of the play mode.

03:56.030 --> 03:57.650
Let's do interpolate here.

03:58.280 --> 03:58.790
Okay?

03:58.790 --> 03:59.150
Okay.

03:59.150 --> 04:00.350
This is good enough.

04:00.350 --> 04:02.720
I think we did a good job for this video.

04:02.720 --> 04:05.840
It was very short but very important I think.

04:05.840 --> 04:08.900
And yeah I think that's it for now.

04:08.900 --> 04:10.220
Let's go to the next video.
