We need to make transition from animation state.
Basically, we need to make transition between animation.
So if we select our player game object in the hierarchy, then move over to this animator tab.
We can see we have two animation.
So this player underscore run animation clip is the default one.
Basically if we just click on this play button in the top, you will see this animation.
Just gonna play right away as soon as the game started.
And let's suppose you just want to make any other state, any other animation state a default one,
then you can do that as well.
So as you can see, as soon as the game started, we can see this player just playing the run animation
clip over again and again.
So let's suppose you just want to make this jump animation clip to be the default one.
So you what you basically have to do, you need to select the animation clip first, then right click
on it and then click on this.
Click on this set as layer default state as.
As soon as we have chosen we can see now player underscore jump animation clip is the default one.
So we don't want this to be default one.
This jump one.
Instead, we want the player underscore run animation clip to be the default one.
So we're going to get out of play mode.
And we're going to make this player underscore run animation clip to be the default one.
So let's right click on it and then click on set as default state.
So what we need to do now we need to make transition between these animation state.
So let's suppose we jump.
So in that moment we need to play this jump animation clip instead of this run.
And as soon as this player game object just gonna land on top of this ground at that moment, we're
gonna play this run animation clip.
So while we are jumping, then we're gonna make a basically we're gonna play this player jump animation
clip.
And once this player game object are running on the ground, then at that moment we're gonna play this
run animation clip.
So we need to make transition between this animation state.
So what we need to do we need to make transition.
So let's do transition.
So we're going to select our player underscore run animation clip, then right click on it and make
transition to player jump.
And then select this transition or this arrow.
Then go over to Inspector in the right.
And we're going to untick.
This has exit time.
Why.
Because as soon as we press down Space Key then we just want to play this jump animation clip right
away.
We don't want any delay.
So that's why we just untick.
This has exit time as well as we're going to set the transition duration to zero.
We're not gonna delay.
And if we scroll down we need to choose a condition in which condition.
We just want to play this jump animation clip of this player game object.
So I'm gonna choose a some certain condition or parameters.
So if you just move over to this animator tab in the left side you can see layers and we have parameters.
So just move over to this parameter section and then click on this plus icon.
And we're going to choose this ball in the bottom pool which can be true or false.
And we have to name the parameter what with what we would like to go with.
So I'm going to call it something like jump.
So let's call that jump and then select this arrow or this transition over to Inspector.
Scroll down and then click on this plus icon in order to choose the parameter.
So we're going to choose is jump is true.
So now if I just click on this play button and then try to set this jump parameter uh to manually true
to false.
So this bull can be true or false.
It's going to have to value.
It can be true or false.
So now if we set our manually basically check this jump parameter to true means check.
As soon as we check we can see this player game object.
Now plays this jump animation clip.
So we need to set this jump parameter to true.
Basically check.
And once we set we're going to play.
Uh it just plays jump animation clip of this player game object.
Why.
Because if we select this arrow from this run to jump and then go over to Inspector, scroll down,
we can see we have chosen that condition if jump is true.
So it's going to play the jump animation clip right away, but once we set this jump parameter to false,
basically uncheck we not playing this run animation clip once again.
So we also need to make transition from this player jump to player run or we will stuck in this jump
animation clip forever.
So let's get out of play mode by clicking on this play button in the top.
And let's make transition back to this player.
Run from this player jump.
So let's right click on this player jump and make transition back to player run and then select this
transition.
Then go over to Inspector and we're going to untick.
This has exit time basically as soon as player.
Just going to land top of this ground then I want this I want this run animation clip to be play right
away.
And I don't want any delay.
So that's why I just uncheck has exit time as well as I'm going to choose the transition duration to
zero.
And if we scroll down we need to choose a condition in which condition.
We just want to play this run animation clip.
So I'm going to choose this jump condition.
So let's click on this plus icon.
And now we're going to choose is jump is false.
Basically once we set this jump parameter to uncheck basically means false.
It's going to play the run animation clip of this player game object.
Why?
Because we can see we have chosen that condition once we going back to this run animation clip.
As you can see in the inspector we have chosen, if jump is false, then we're gonna move over to this
run animation clip.
And if we just set this jump parameter to true, we're going to play this jump animation clip of this
player game object.
Why?
Because we can see we have chosen that condition in the inspector.
So let's try to check manually.
So let's click on this play play a play button in the top.
Let's click on this play button in the top and try to set this jump parameter manually to true or false
means uncheck or check.
We will see that now if I set this parameter to true basically means check.
We can see this jump animation clip just plays right away.
And once we set this jump parameter to false means uncheck, we can see the run animation.
Once again it's playing.
Why?
Because we can see if we select the back transition, then go over to Inspector.
Scroll down.
We can see it.
Jump is false.
Then it's gonna play that run animation clip.
And if jump is true, we can see it's gonna play this jump animation clip of this player.
Game over.
Sorry.
Once we set this jump parameter to false, it's gonna play the run animation clip.
And once we set a jump parameter to true, basically means it's going to play the jump animation clip
right away.
So let's get out of play mode.
So we need to control those things with parameter.
So if we select our player game object we can see in the inspector.
We can see a animator component just added up right away once we created this animation clip.
So once we created this run and this player jump animation clip of this player game object, this animator
component, just add right away.
So this animator component.
So we need a reference of this animator component of this player game object.
Then we can make transition between these.
Or we can simply set this jump parameter through our code.
Let's suppose we just press down space key.
Then we want this player game object to jump.
So in that moment we need to set this jump parameter to true.
Basically means check.
And we do know once we set it's going to play the jump animation clip.
So how we can set that.
If we select our player GameObject in the hierarchy then go over to Inspector.
We can see an animator component just added once we created this animation clip.
So we need a reference of this animator component.
Then we can set this parameter to true or False depending upon what player actually doing.
So we need a reference and we can see a plus icon just became a of in this animator component.
So what we basically need to do we need to go over to overrides and then top up inspector overrides
and then click on this apply all.
So if I just move over to this project tab then assets and then prefabs or folder and open up the player
prefab means copy of this game object by double clicking on it.
We can not able to see in inspector any animator component.
Added to this player game object.
So what we basically need to do we need to go back.
So in hierarchy you can see the back arrow.
So just click click there in order to go back and then select this player game object.
Then go over to Inspector Overrides and then click on Apply All.
As soon as we click on Apply All the plus icon just gone by now.
And if we now try to open up the player prefab from that folder by double clicking on it, we can see
animator component is attached by.
Now to this player game object.
So what we basically need to do whatever changes we made in this hierarchy of this player game object
in Inspector, we can just click on overrides and then apply all the changes we made in this player
game object in hierarchy.
It's going to be saved into prefab of this game object as well means copy of that game object.
So make sure you just go to Inspector then overrides and then click on Apply Wall.
So the changes you made over here, it's going to be saved into this player GameObject prefab as well.