Let's make transition between this animation clip.
So make sure you select your animator GameObject in the hierarchy.
Then move over to animator tab.
And if you're not able to find your animator tab, then go over to window in the top.
Then scroll down to animation and you can see the animation as well as the animator tab.
And after selecting our animator game object in the hierarchy and move over to animator tab, we can
see all of the animation clip.
We have the enemy to attack, enemy to death, enemy to hard.
So we need to make transition between this animation clip.
So we will do the same thing as we have done with our first enemy, one game object.
So we will approach the same way.
So let's right click on this enemy to work.
And let's click on Make Transition to our enemy to attack.
And let's select this transition or this arrow.
Go over to Inspector.
We're gonna uncheck.
This has exit time because as soon as this player gets in attack attack range we just want to play this
animation clip right away.
So that's why we just uncheck that has exit time and also transition duration.
We're gonna set it to zero as zero.
And if we scroll down we need to choose a condition in which condition we want to play that animation
clip which is enemy to attack animation.
So let's create a variable for it.
So so let's go over to animator tab a animator tab and then parameters.
Let's click on this plus icon.
And we're gonna choose a bool parameter which can be true or false.
And we can call this one attack.
And we're gonna choose this condition.
So let's go over to Inspector.
Make sure you select your transition.
Go over to Inspector.
Scroll down to the bottom and then click on this plus icon.
And we're gonna choose if attack is true.
And we also need to make a make transition back to our work.
Or we will stack forever into this enemy to attack animation clip.
So let's right click on this enemy to attack.
And let's make transition back to our work and let's select the back transition.
Let's go over to Inspector.
Let's uncheck.
This has exit time as well as transition duration to zero.
And we're going to scroll down.
And now we're going to click on this plus icon.
And we will choose if attack is false.
So if attack is false then it's going to play that animation clip.
Uh so for this moment I'm going to make my anime work speed a little bit, a little bit less.
So I'm going to select my animator game object in the hierarchy.
Let's go over to Inspector then Animator Script, and I'm going to make the workspace.
So uh, to something like 0.1 I'm just doing for testing purposes only.
And if we go ahead and then play, but click on this play button in the top in order to play our game
and try to trigger the sorry, try to set this attack parameter manually to true or false basically
means uncheck or check.
You will see the transition going to happen.
So if I move over to my animator tab and if I just manually set it to true basically checked, we can
see enemy to attack animation is playing over again and again.
And if I set it to uncheck basically false, we can see by now it's playing that work animation clip.
So we need to set this parameter through our code.
So let's get out of play mode.
And let's make also transition to this enemy heart.
And we're gonna make this animation a clip from any state.
Uh, no matter if we are working or applying attack animation clip, if we take damage, then this enemy
to game object need to play the heart animation clip right away.
So that's why we're gonna make the transition from any state.
So let's right click on this any state and let's make transition to our enemy heart to and let's select
this transition.
Let's go over to Inspector.
And then we're gonna uncheck this as exit time.
Because as soon as we're gonna take damage from this player game object, and then this animated game
object need to play the heart animation clip right away.
So that's why we uncheck the has exit time.
And let's see this transition duration to zero.
And if we scroll down we need to choose a condition.
So let's choose a trigger condition for it.
So let's move over to animator tab parameters.
Let's click on this plus icon.
And we're going to choose a trigger.
And we can call this trigger to something like Heart or Damage.
So let's call it heart.
Let's go over to Inspector.
And we're going to click on this plus icon.
And we're going to choose that heart trigger heart parameter or that heart condition.
So if we just trigger this parameter then this heart to animation clip.
Just gonna play of this animator game object right away.
So we also need to make transition to this enemy to work as well as enemy to attack.
Or we will stuck forever into this heart animation clip.
So let's right click on this animator heart.
And we're going to make transition to animated work as well as let's right click on it and let's make
transition to enemy to attack.
And now we're going to select this transition.
So let's select from this heart to our idol first.
And then go over to Inspector.
And we're going to leave the exit time.
This has exit time as well as exit time.
We will choose one.
Why.
Because we want to play the heart animation clip of this enemy two game object 100%.
And after that we want to play the work animation clip.
So that's why we just leave the has exit time and transition duration.
We're going to set it to zero.
And if we scroll down we can choose a condition.
And let's suppose you don't choose a any condition.
Then it's automatically gonna play the work animation clip of this enemy to game object.
So since we have a condition which is are at attack or let's, let's, uh, let's skip that.
We're not gonna choose any condition from this hard to work animation clip.
So basically it's going to play the heart animation clip.
And once it's played 100%, then it's gonna move over to this work animation clip of this anime two
game object automatically if we don't choose any condition.
But for in this attack condition from this anime to heart to our attack.
So let's select that transition.
We're gonna choose a condition for it.
So let's go over to Inspector first.
And we're going to leave this as time and exit time.
We're going to choose one basically means 100%.
We're gonna play and we will set transition duration to zero.
And if we scroll down we need to choose a condition.
So for this we're gonna choose this plus icon.
Let's click on this plus icon.
And we will check if attack is true.
And we do know that if we set this attack parameter is true, it's gonna play this attack to animation
clip instead of the work.
So that's why we have chosen that condition.
And if you don't choose any condition as well, if you just remove that and it's gonna move over to
this attack.
Animation clip.
Enemy to attack animation clip automatically depending upon where player is.
If the player is inside attack range, then it's gonna play the attack animation clip.
If it's not, then it's gonna play the animation clip so you can choose the condition.
It's totally up to you.
If you don't want then you can just remove it.
But for attack I just did it.
You can just skip that as well if you want.
And now we need to make transition enemy to that.
But before we do, let's try to trigger this hard parameter manually if it's working or not.
So basically we just want to check.
So let's click on this play button in the top in order to play our game.
And let's trigger this hard parameter manually.
If we trigger it it's going to play the hard animation clip of this enemy to game object instead of
work or attack right away.
So if I try to trigger this parameter, as you can see, as soon as we playing, this enemy just plays
that heart animation clip.
And once it's played 100%, it just move it over to this work animation clip automatically.
But if the player in attack range, then it's going to play this animation clip.
So if I take my player and then move it over here, something like that, and then move over to animator
tab and select this animator GameObject in the hierarchy.
And if I set this attack parameter to true, now it's playing the attack animation clip instead of the
work.
Why?
Because this player inside this attack range radius as you can notice.
So that's why.
So I hope you get the idea.
And now we're gonna get out of play mode.
And what we will do, we need to make transition to this enemy to that uh, by now.
And we're going to make it from any state.
So let's right click on this any state and let's make transition to enemy to that animation clip.
Why we made from this any state, no matter what state we are in.
Basically, if the player is walking, taking, taking damage from this enemy came up.
Sorry from this player game object or this enemy to game objects playing the attack to animation clip.
If it's lose all of his health, then it's need to play the death animation clip of this enemy to game
object right away.
No matter what we doing, like playing attack or walking.
So that's why we just making transition from any state.
And we're gonna select this transition.
Let's go over to Inspector.
And now we're going to leave the has exit time and exit time.
We're going to choose one.
And because we want to play the death animation clip of this enemy to game object are 100%.
So that's why.
And transition duration we're gonna set it to zero.
And if we scroll down we're going to choose a second trigger or a another trigger parameter for this.
So let's create that.
So we will move over to animator tab then parameters.
Let's click on this plus icon.
And we're going to choose a trigger and we have to name the trigger or the condition.
So let's call it something like death.
And uh, and we're going to choose this trigger parameter or that condition.
So let's go over to Inspector then scroll down to the bottom condition and let's click on this plus
icon.
And now we're going to choose that death trigger, that trigger condition or that parameter.
So now if we go ahead and then play hit this play button in the top and manually try to trigger this
death parameter.
You will see the death animation just going to play right away.
So let's have a look.
So if I trigger this death parameter, as you can see, as soon as we trigger it we just play that.
And we're not making from uh, making transition from this enemy to, to our attack heart or a work.
Why?
Because once it loses all of his health, then it's need to be destroyed.
So that's why we're not making this, uh, not making any transition from this enemy to that animation
clip to heart attack or work.
So that is the reason.
So I'm going to get out of play mode.
So I hope you get the idea that how you can make transition between this animation clip.
So you need to choose some certain condition and some certain condition.
So you can just make that.
You can make the transition between this animation clip.
And we need to set this parameter through our code depending upon where player is.
If the player in attack range attack range radius are, then this enemy need to play this animation
clip which says enemy to attack and if the player is not are not inside of it then it's need to play
the work.
So we need to set this parameter, this attack heart and the death through our scripting of this enemy
to game object.
So I hope you get the idea that how you can do it and make sure you press down Ctrl s on your keyboard
in order to save your project.
So I hope you get the idea of it.