Now we need to make transition between those animation clips.
So let's select this animation in the hierarchy.
Let's go over to animator tab so we can see all of these animation clip.
Uh so if we just go ahead and then click on this play button in the top you will see this anime one
underscore idle just gonna play right after the game start.
Why?
Because this one the default animation clip.
So that is the reason.
And we also need to make a transition between this arrow fire heart and death.
So just wait a little moment.
Uh, so as you can see, as soon as our game started this anime one, just playing the idle animation
clip over again and again, and we can see, uh, we can notice in our animator tab.
So let's get out of play mode and let's make transition between this animation clip.
So let's right click on this idle make transition to Arrow Fire.
And let's select this transition.
Go over to Inspector.
We're gonna untick.
This has exit time because as soon as our player just gets in attack range.
This enemy need to fire the arrow right away.
Also, we will choose 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 for that we will choose a bool parameter.
So let's head over to animator tab.
So let's click select this parameters.
Then click on this plus icon.
And let's choose a bool.
And we can call this one range in range.
So let's call it instead in range in range.
So we will go over to Inspector.
Let's click on this plus icon in this condition.
And we will choose if in range is true.
If that is the case then it's gonna play the arrow enemy arrow enemy one arrow fire animation clip right
away of this enemy one game object.
And also we need to make transition back to our idle or we will stack forever into this enemy.
One arrow fire animation clip.
So let's right click on it and let's make transition back to our anime -- idol.
And let's select this transition.
Let's go over to Inspector and we're gonna untick this axis time.
Or we can just leave it.
Uh, or we can just simply uncheck that has exit time.
So as soon as this player in not attack range of this anime game object enemy one game object, then
this enemy one game object need to play this idle animation clip.
So that's why we just uncheck the has exit time.
We're gonna do it immediately.
And transition duration.
Let's set it to zero.
And if we scroll down we need to choose a condition in which condition.
We want to play this idle animation clip of this anime one.
So let's click on this plus icon.
And now we're gonna choose if in range is false.
So we will uh check.
We will set this.
If in range is false then it's gonna play the idle animation clip.
So if we just go ahead and then click on this play button in order to start our game and then manually
set this parameter to check or uncheck, basically setting it to True or False.
You will see the animation just gonna play.
So if I go if I go my animator tab and set this in range parameter manually to true or check.
As you can see it's playing the arrow animation clip over again and again.
And if I uncheck or set this in range parameter to false manually, we can see that it's now playing
the idle animation clip of this anime one.
So we need to set this in range parameter through our code.
And we need to check the distance between our player or with this anime.
So if the player just came in attack range, then this enemy need to play this arrow fire animation
clip.
So basically we need to set this in range parameter to true.
And we don't know once we're gonna set it it's gonna play that animation clip as you can see.
And if we set it to false we can see it's now playing the An idle animation clip.
So let's get out of play mode.
And let's also make transition to this heart and death.
And we're going to do it any state.
Let's suppose this enemy game object attack on this enemy.
Sorry.
Let's let's suppose this player game object attack on this enemy.
One game object.
Then this enemy need to play a heart animation clip instead of playing the idle or arrow fire, it should
play the heart since we damage this enemy one game object.
So that's why we're going to make the transition from any state to heart.
So let's right click on any state.
Let's make transition to our heart.
And let's select this transition.
Let's go over to Inspector.
And we're going to uncheck.
This has exit time and transition duration to zero.
And if we scroll down we need to choose a condition.
So what we will do for this we're going to choose a trigger.
So let's head over to animator.
Let's click on this plus icon.
And let's choose a trigger.
And we can call this trigger to heart or heart something like that.
Or you can call this one damage as well.
So we also need to make transition to idle or arrow fire arrow fire or we will stack forever into this
enemy one underscore heart animation clip.
So let's right click on it.
And let's make transition to idle as well as let's right click on it.
Make transition to arrow fire.
And let's select the transition from this heart to our idle.
So we will go over to Inspector.
And we're gonna leave the has exit time because we want to play the idle sorry heart animation clip.
So that's why.
And we will choose exit time to one.
So one basically means we do know that it's gonna play the 100% animation clip of of this enemy one
heart.
And after that it's gonna move over to Idle Animation clip, and we will set the transition duration
to zero.
And if we scroll down, uh, we, uh, if you want to choose the condition, you can do it.
And if you don't want to choose any condition, then it's it's automatically just gonna move over to
this anime one underscore idle animation clip.
Once the anime one underscore animation clip played 100%.
So make sure you leave.
This has exit time to tick, and we're gonna do the same thing from this heart to our arrow fire.
So we will leave the has exit time and exit time to one, transition duration to zero.
And if we don't choose any condition, then it's gonna play that animation for this hard to our arrow
fire.
I'm gonna, I'm gonna say something like, so let's click on this plus icon and we're gonna choose this.
If in range is true.
And we do know that if in range is true basically means this player just come comes in attack range
of this enemy one, then this enemy one need to play the arrow fire.
So that's why we have chosen that condition.
And for this heart, from this heart to our idle, we can choose this in range to false, something
like this.
Or if you just remove that condition by clicking on this icon and you don't choose any condition.
So in that moment, after playing the heart animation clip, it's just gonna move over to this enemy
one underscore idle animation clip automatically, so you don't need to choose the condition, but if
you do one, then you can choose that.
It's basically totally up to you, but I'm not gonna do it.
And we can do the same thing in this, uh, from this heart to our arrow fire, we can remove the condition.
Uh, but for this arrow fire, I'm gonna leave that.
So now if we go ahead and then manually trigger this heart parameter, you will see heart animation.
Just gonna play.
And after playing 100%, it's just gonna move over to arrow fire or idle, depending upon where player
is.
But we gonna talk about it later.
So if I move over to animator tab and then trigger this heart parameter manually, uh, manually, we
cannot able to see basically what we have to do.
Let's get out of play mode.
Uh, basically, we forgot to loop the animation.
So if I head over to my project app assets, then animations folder and my animations folder anime one
animations folder.
And if we choose the hard one, we're going to check this loop time.
And now if we go ahead and then click on this play button and then try to trigger that hard parameter
manually, we should able to see.
So just wait a little moment.
So now if I choose my animator tab uh but but before you choose make sure you select your anime one
in the hierarchy, then move over to animator tab.
And if we trigger this hard parameter manually, we not able to see because we forgot to choose that
condition.
Basically, what we have to do if we get out of play mode and then choose this arrow, then go over
to Inspector.
Scroll down.
As you can see, we haven't choose this hard condition, so we need to choose that.
So that's why we're not playing this hard animation clip of this anime one.
So we need to choose this hard heart trigger parameter condition.
So whenever we're going to trigger it it's going to play this heart animation clip.
So if we go over to Inspector and then scroll down we can see list is empty.
Basically we haven't used any condition.
So let's click on this plus icon.
So we're going to choose our trigger.
So let's click here.
And we're going to choose this heart.
So basically means that if we trigger this heart parameter it's going to play the heart animation clip
of this anime one right away.
And after playing that it's going to move over to idle or arrow fire depending upon where player is.
But we have to do it inside through our code and we're going to talk about it later.
And also I want to uncheck the loop time of that heart animation clip of this anime one, because we
have done the mistake here, not there.
So let's head over to our project app one more time.
Assets.
Animation, anime, animation, anime one underscore animation.
And let's choose the heart one and uncheck the loop time in the inspector.
And now if we select our enemy one inch the hierarchy, move over to animator tab and then click on
this plus icon.
Now we should able to see because we have chosen this hard trigger condition by now means that if we
trigger this parameter manually, it should play the heart animation clip of this enemy one right away.
So if I try to trigger this heart parameter manually, as you can see, as soon as we triggering, it's
playing the heart animation clip.
And once our heart animation clip played completely, it just move over to this idle.
And if the player in attack range then it's it's gonna play this animation clip and we have to do with
our code.
So I hope you get the idea that how you can just do it, we're doing it manually.
Instead of doing this manually, we need to do through our code.
And we also make also need to make transition to this enemy one underscore death.
So let's get out of play mode.
So we also need to make transition to animated anime.
One underscore that, and we need to make this transition from any state.
Let's suppose this anime loses all of his health, then it's need to play the anime one death animation
clip right away, no matter what this player is really doing.
Like, uh, playing the animation clip or heart, it doesn't need to be because once this anime one
loses all of his health, then this anime one need to play the death animation clip right away instead
of playing any other animation clip.
So that's why we're going to make transition from this state.
Uh, and we need to we're going to choose a condition for this as well.
So let's right click on this any state and let's make transition to anime one underscore death.
And now let's choose this transition.
Go over to Inspector.
And we're going to leave this as exit time.
And this exit time we're going to choose one and transition duration to zero.
Why we have chosen one because we want to play the death animation clip of this enemy 100%.
So that's why we just leave it to one.
And if we scroll down, we need to choose a condition.
So we're gonna choose a trigger condition for this enemy one.
So let's go over to animator.
Let's click on this plus icon.
Let's choose a trigger.
And we're going to call this trigger to something like that.
And we're gonna choose this condition or this trigger condition.
So let's click on this plus icon in the inspector.
And we're gonna choose this trigger condition.
And we're not gonna make a transition from this state to heart idle or arrow fire, since our enemy
loses all of his health.
So that's why we're not gonna make transition, uh, from this state to heart or idle or arrow fire.
So we're gonna leave that.
So now, if we go ahead and then click on this play button and manually try to trigger this death parameter,
you will see that death animation just gonna play.
And after playing it's not gonna play any other animation clip since we didn't make any transition from
this state.
So if I try to trigger this state parameter, as you can see, it's played that and it's not, move
it over to any other animation clip because we don't want be cause this enemy game object just loses
all of his health.
Then it's a need to stop playing hard or idle.
Since this is since our enemy game object loses all of his health, so we're doing it manually.
So instead of doing this manually, we need to do with our scripting with scripting.
So I'm gonna get out of play mode.
So I hope you get the idea that how you can do it.
And we need to create a script in order to trigger or set this parameter through our code, depending
upon where player is.
If the player gets in attack range, then we basically need to trigger this parameter or basically taking
damages from this player game object.
So I hope you get the idea that how you can make transition between these animation clips.