Hello guys.
Welcome to the video.
In this one I want to show you how to work with a blend tree and how blend tree can be useful in the
animator at all.
So first let's create a blend tree and see what it does.
We're going to click create button over here.
Create state from New Blend Tree.
Now let's select it and name it as Idle Slash Move.
And inside you can select the blend tree and you can add a bunch of motions.
Here I'm going to click add motion.
Add motion.
Now let's select.
Player move.
Layer idol and layer move.
We can open preview over here and if we click play button you can see animation being played.
Now let's uncheck Automate threshold over here.
And let's do minus one.
Zero one.
Now this threshold will control transition between animations by itself.
So if we have value at zero, then player will stand in the idle animation.
If we move value to the left to the negative value.
You can see player is in the running animation if we go back to zero.
He stands in the idol.
If we increase the value, he goes to the running animation again.
And this can be used to control idle and move animation instead of these two animations with the transitions.
All right, let's just go inside.
And we need to rename this parameter over here.
I'm going to name it as x velocity.
And then we need to be sure this parameter is selected over here.
X velocity.
Now let's go back to base layer.
We can delete these two.
I just wanted to show you an example on how it could work.
But don't be sorry.
Just remove them.
And this blend tree will become a default state animation of the player.
We can delete this parameter as well, and we can only update this animation by updating info on the
x velocity.
And that would do the entire job for us with the transitions.
Very convenient way.
Very clean I think.
Very efficient.
So let's go to player script.
And over here, instead of setting boolean, we can just type.
Einem said float of the x velocity.
And again I'm scared I'll make a mistake.
So I'll go here.
I'll copy this, go back to script, paste this in, and then as a value that we want to have for that
parameter we're going to pass rb velocity dot x.
And that's it.
Simple as that.
Now let's save this and go back to unity.
And see if it's working.
Idol.
Move.
Mauve idol.
Very cool.
Love it so much, man.
Really nice.
Um, I can see there is a bit of a jittering effect when we move in.
You can see on the character he sort of jittering.
To fix that, we can go to the rigid body.
And go to interpolate and choose interpolate.
Now when we move, it's going to feel smooth and nice.
It has to do with the update of a physics.
It's not that important right now.
All right.
Very good.
Oh, we need to do this out of the play mode.
Let's do interpolate here.
Okay?
Okay.
This is good enough.
I think we did a good job for this video.
It was very short but very important I think.
And yeah I think that's it for now.
Let's go to the next video.