Now we need to make animation transition.
So if I select my player GameObject in the hierarchy and then move over to animator tab, as you can
see, we have uh, we are already created multiple animation clip.
We have player run, player jump, player attack and all of these.
So if you're not able to find the animator tab then go to window in the top, then animation in the
bottom and then animator tab and you're gonna get it.
So we have this animation clip and I'm gonna drag it up.
So we need to make transition between this animation clip.
So before I do and then click on this play button in the top, you will see uh right after the game
start this player idle animation just gonna play.
Why?
Because that one is the default one.
And let's suppose you want another animation clip to be default one.
Then you have to do something else.
As you can see, as soon as our game started, we can see this player just playing the player idle animation
clip over again and again.
And so let's suppose you want this animation clip which is player underscore run.
Then right click on it and then set as layer default state.
And as soon as we set we can see this player run is now the is now basically the default state by it.
I want to live with this player idle.
So I'm gonna set that player set as default state and I'm gonna get out of play mode.
So we need to make transition between this animation clip from this player idle to player run, player
jump, player attack one, attack two, attack three, and all of these to do so, what we basically
have to do, we need to right click on this player idle Animation clip and then click on this make transition.
And let's make transition to this player run.
And now if we select this transition or this arrow and then go over to Inspector.
As you can see it says has exit time.
So we're gonna uncheck this because we're gonna make the transition right away and transition duration,
we're going to set it to zero.
And if we scroll down, we need to choose a condition in which condition we want to play that animation
clip.
So we need to set some certain condition in order to play this animation clip.
So in animator tab we can see layers and then these parameters.
So let's click on this plus icon.
And I'm going to choose a float parameter.
And we can call this parameter whatever you like.
So let's call it something like run.
And now we're going to choose this condition if run.
So to choose this condition go over to Inspector and make sure you select that transition.
Go over to Inspector and then click on scroll down to the bottom and then click on this plus icon.
And we will choose that.
If run is greater than and we're going to check with smaller number something like 0.01 or or we can
check with .0.1.
So with some smaller number something like 0.1.
So if our run parameter is greater than 0.1, then we want to play this player run animation clip.
Because as you can see we have chosen that condition.
So we have chosen that if run parameter is greater than 0.1.
So let's suppose we set this one to something like one.
And one will be definitely just gonna be definitely gonna be greater than point one.
So the condition is becoming true.
So that's why this player run animation gonna play and let me show you.
So if I just go ahead and then click on this play button and then manually set this run parameter to
something like 0.2 or 1.
And then it's going to play the player run animation clip.
Why?
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
than point one.
So if I set this run parameter to one inch my animator tab, as you can see, as soon as we have chosen
one it's playing the player.
Underscore run animation clip.
Why?
Because we set this run one and one is greater than 0.1.
So the condition is becoming true.
So that's why this animation is playing.
And if we set back to zero it's not playing at all the idle animation clip.
Uh, why?
Because we also need to make transition back to our idle.
So to do that, let's get out of play mode.
And let's right click on this player underscore run and then make transition back to player idle.
And we're going to choose this transition or this condition.
Then go over to Inspector.
And we're gonna untick.
This has exit time because we want to play the player idle animation clip.
As soon as they as soon as this player stops running or stops moving.
And also let's set the transition duration to zero.
And if we scroll down and we need to choose a condition.
So we're gonna choose the same condition with a different state.
So basically we're going to click on this plus icon.
And now we're going to choose if run is lesser than with a smaller number something like 0.1 as we have
done from this player idol to player run.
So if we set this player run to zero, and we do know that if we set this run parameter to zero and
zero will be lesser than 0.1.
So the condition is becoming true.
And let's suppose we set this run parameter to something like minus one.
And minus one will definitely gonna be lesser than 0.1, because minus one is lesser than 0.1.
So the condition is becoming true.
So that's why it's gonna play the idle animation clip.
Or else we can set this parameter to zero and zero will be lesser than 0.1.
We do know.
So the condition is becoming true.
So that's why this player idle animation gonna play instead of the run.
Once we set back this run parameter to zero.
Let me show you.
So let's click on this play button in the top in order to start our game.
And let's check it one more time.
So if we set this one parameter to one, then it's gonna play the run animation clip.
And if we set this run parameter to back to zero it's gonna play the idle animation clip.
So if I set this run parameter to one, as you can see, as soon as we have set this one parameter to
one, it's playing the player underscore run animation clip.
Why?
Because if we set this run to one and one will be greater than 0.1.
So the condition is becoming true.
So that's why this player underscore run animation is playing.
And if we set this manually this run parameter to zero.
As you can see as soon as we have chosen zero it's playing the player idle animation clip.
Why.
If we choose the back transition then go over to Inspector.
We can see if we set this run to zero.
So zero will be less than 0.1.
So the the condition becoming true.
So that is the main reason it's playing the player.
Underscore idle animation clip.
So basically we need to set this one parameter through our code.
Basically once we start moving then we're going to set this parameter to one.
So it will play the run animation clip.
And once we're gonna set back this run parameter to zero through our code.
Basically once we stop moving then we're gonna set this run parameter to zero.
So it will play the player underscore idle animation clip.
So let's get out of play mode.
And also let's make transition from this player idle uh, to this player jump basically from any transition.
We want to make the jump no matter what state we are in.
Let's suppose this player, a player is running, and then we simply press down space key on our keyboard.
Then we want to play the jump animation right away, no matter if this player is running or standing
at one point.
So we want to play the player jump animation clip right away.
No matter what we're doing.
So that's why we're going to make transition from this anime state.
So we will right click on this any state, then make transition to player jump.
And let's choose this transition.
Let's go over to Inspector and we're gonna untick.
This has exit time as well as we will set the fixed duration uh the transition duration to zero.
And if we scroll down we need to choose a condition in which condition?
We want to play that animation clip.
So we're gonna choose a second condition or a parameter for, uh, for in order to make our player jump
animation clip.
To do so let's click on this plus icon.
And now we're gonna choose a bool parameter which can be true or false.
And let's call this one something like jump.
And sorry to rename this you can just double click on it.
And we're going to call this jump.
And we want to choose this condition.
So let's go over to Inspector and let's click on this plus icon.
And we're gonna choose this jump parameter.
So we will set if if jump parameter is true.
Basically if we check it check basically means that we just setting it to true.
It's going to play the player jump animation clip.
So let me show you.
So let's click on this play button in the top uh top to play our game.
And if we set this jump parameter manually to true basically means check.
You will see this player jump animation.
Just gonna play right away right away.
So let's have a look on it.
So if I check this one parameter sorry this jump parameter to check.
Basically true.
Uh, we just setting it to true.
As you can see, as soon as we just setting it to true it's played the player jump.
But the but the problem is that we stuck at jump animation clip.
So we also need to go back to player idle as well as player run.
Depending upon what player is doing, it's uh, if the player is running.
Uh, sorry.
If the player is moving to the left or right direction.
So in that moment, we need to make transition from this player jump to player run.
And if the player stops moving, then in that moment we need to play the player ideal instead of the
player run.
So let's get out of play mode.
So from this player jump we also gonna make a two player ideal.
So let's right click on it.
Player jump animation clip and make transition to player ideal.
And let's choose this transition.
And we will go over to Inspector.
And we will uncheck the has exit time.
Because as soon as we touch our crown or uh ground or you can simply say ground, then we want to play
the idle animation clip right away.
So that's why we just uncheck has exit time.
Also let's say this transition duration to zero.
And if we scroll down we need to choose the condition.
So we're gonna choose that condition.
So let's click on this plus icon.
Firstly we're going to choose if jump.
So we're going to set this jump parameter to false.
Basically if we uncheck this jump parameter to uncheck this jump parameter basically means we set it
to false.
Then it's going to play the player idle animation clip.
And we can choose a second condition as well which is the run.
So we're going to choose if run is less than 0.1.
If that is the case.
And we do know that once it's less than 0.1 basically means we stop smoking.
So in that moment we're going to play the idle animation clip.
And we do know that once we stop moving, we're gonna set this parameter to zero.
And zero will be less than 0.1.
So the condition is becoming true.
And also if we set this parameter to false basically uncheck you will see this idle animation just gonna
play instead of this running one.
So we also need to make transition from this player jump to player run.
If the player is moving to the right or left direction.
So let's right click on this player underscore jump.
And let's make a let's make transition to player run.
And let's select this transition.
Let's go over to Inspector.
And we're going to uncheck has exit time.
And also let's set the transition duration to zero.
And let's scroll down.
So we need to choose a condition.
So we're going to choose two condition.
So first condition we will choose if jump parameter is false.
If that is the case.
And the second parameter we're going to choose if run is greater than 0.1.
If that is the case means if we set this parameter to one so one will be greater than 0.1.
So we do know that it's it's going to play the run animation clip instead of the idle as soon as we
touches our ground.
So let me show you.
So let's click on this play button in the top.
And if we set this jump parameter to manually check or uncheck basically true or false, you will see
it's gonna play the run up.
Sorry.
It's gonna play the idle animation or run animation clip depending upon what player is really doing.
So if I check this one parameter to true, basically.
Uh, true.
As you can see, it's played the jump.
And if I uncheck it, we can see it's played the player idle instead of the player run.
Why?
Because this player is not moving at all.
So that's why.
And we're gonna set this, uh, parameters through our code.
And I'm doing manually to just explain this.
So let's get out of play mode, and let's also make transition to this player attack player attack two
and player attack three.
And we're gonna make transition.
Once our player stops moving, basically a player is standing at one point.
Then we want to play this animation clip.
If the player is moving or jumping then we don't want to play this.
Attack three, attack two or attack one.
animation clip of this player.
So we all only want to make transition from this player idle if the player just standing at one point.
I really apologize for the noises.
Uh, so what we're gonna do, we're gonna make transition from, uh, from this player idle to player
attack one, attack two, and this attack three.
So let's make transition.
So let's right click on this, uh, player idle.
And let's make transition to player attack one.
And let's choose this transition.
Let's go over to Inspector and we're gonna untick.
This has exit time and transition uh fixed duration.
We're gonna uncheck or we can just leave it and transition duration.
We can set it to zero.
And if we scroll down, we need to choose a condition in which condition we want to play this attack
one animation clip.
So what we're gonna do, let's take a look in the next lecture of it.