Hello, guys.
Welcome to new video.
And in here we're going to make character run and I mean animation.
We're going to make a running animation.
Let's go to animation window over here and create new clip in the animations folder.
It's going to be player move, save it, go to graphics player and run.
Let's take all of these sprites and drag them here.
And I'm going to set sample rate 12.
Later on we're going to change the animation speed according to the speed of the player.
But for now, let's just keep 12.
Now if we go to animator, we can see that animation is there, but it's not connected to the main tree
anyhow.
And now we cannot use it, but we want to use it.
And to do that we're going to use parameter.
So let's hit this plus icon and we can choose one of four and I'm going to choose boolean that will
be named as ease running.
Now let's make transition from idle to move and from move to idle.
If we select this transition on the right side, we can see condition for it.
So let's set condition for one true and for another one false.
Now let's try that.
Let's go to play mode.
Have Bullen over here and if I check it.
I can see I'm running if I check it again.
I am not running.
And if you notice, there are a slight delay between animations.
To fix that.
We're going to select this transition.
Open settings and and make transition duration zero as well.
We want to uncheck exit time and same for another one.
Now, if I go to play mode and check this box, my transition is instant.
Our next step would be make this transition from the code so we don't have to click this checkbox manually.
We can do that by going to script again and maybe in the update.
Let's create a boolean and I'll just make it public because we need it real quick.
Public is public, bool is running now.
Let's go to update and type anim set.
Bool.
So you know what we do in rate animals is.
This.
Animator.
This one.
Let me open it.
So this animator is exactly this animator.
And if we go back to code.
We know that.
This animator is exactly this animator because we get an access to, again, this animator from here.
Got it.
Cool.
Now we're saying anim set, bool, and we need the name of Bolan and we know that name is is running
and let's set it to value of is running.
Now, if I go back to Unity and hit play and can see my character standing, if I check this box is
running here going to run and again and again.
So we control this balloon by controlling this balloon.
Now all what we need to do is to control this balloon according to the speed of the player, not by
clicking the mouse.
So let's go back.
And in the update, I'm going to type is running equals to RB dot velocity, dot x, not equals to zero.
OC.
And I can make it private.
Private.
So now this boolean will be true only.
If velocity of the x not equals to zero.
Now let's go back and check it in the action.
Yeah, works.
And now, before we finish this video, let's do a bit of clean up.
What I want to do here is I want to create a function for animations only.
So let's select this click alt enter to call submenu, and we're going to choose extract method.
I'm going to name this as animator.
Controllers.
OC save it.
And I think that's enough for this video.
Let's go to the next one.