WEBVTT

00:00.040 --> 00:03.120
Let's make transition between this animation clip.

00:03.120 --> 00:06.480
So make sure you select your animator GameObject in the hierarchy.

00:06.480 --> 00:08.520
Then move over to animator tab.

00:08.680 --> 00:14.080
And if you're not able to find your animator tab, then go over to window in the top.

00:14.120 --> 00:19.840
Then scroll down to animation and you can see the animation as well as the animator tab.

00:20.240 --> 00:26.240
And after selecting our animator game object in the hierarchy and move over to animator tab, we can

00:26.240 --> 00:28.480
see all of the animation clip.

00:28.480 --> 00:32.320
We have the enemy to attack, enemy to death, enemy to hard.

00:32.320 --> 00:35.680
So we need to make transition between this animation clip.

00:35.680 --> 00:40.760
So we will do the same thing as we have done with our first enemy, one game object.

00:40.760 --> 00:43.080
So we will approach the same way.

00:43.280 --> 00:45.640
So let's right click on this enemy to work.

00:45.640 --> 00:50.360
And let's click on Make Transition to our enemy to attack.

00:50.400 --> 00:52.960
And let's select this transition or this arrow.

00:53.080 --> 00:54.200
Go over to Inspector.

00:54.200 --> 00:55.120
We're gonna uncheck.

00:55.120 --> 01:02.390
This has exit time because as soon as this player gets in attack attack range we just want to play this

01:02.430 --> 01:04.430
animation clip right away.

01:04.590 --> 01:09.390
So that's why we just uncheck that has exit time and also transition duration.

01:09.390 --> 01:12.150
We're gonna set it to zero as zero.

01:12.310 --> 01:18.310
And if we scroll down we need to choose a condition in which condition we want to play that animation

01:18.310 --> 01:21.070
clip which is enemy to attack animation.

01:21.430 --> 01:23.590
So let's create a variable for it.

01:23.590 --> 01:28.950
So so let's go over to animator tab a animator tab and then parameters.

01:28.950 --> 01:30.510
Let's click on this plus icon.

01:30.510 --> 01:34.350
And we're gonna choose a bool parameter which can be true or false.

01:34.350 --> 01:36.590
And we can call this one attack.

01:36.950 --> 01:38.630
And we're gonna choose this condition.

01:38.630 --> 01:40.510
So let's go over to Inspector.

01:40.510 --> 01:42.550
Make sure you select your transition.

01:42.550 --> 01:43.710
Go over to Inspector.

01:43.750 --> 01:46.870
Scroll down to the bottom and then click on this plus icon.

01:46.870 --> 01:49.470
And we're gonna choose if attack is true.

01:49.790 --> 01:53.870
And we also need to make a make transition back to our work.

01:53.910 --> 01:58.910
Or we will stack forever into this enemy to attack animation clip.

01:58.910 --> 02:01.350
So let's right click on this enemy to attack.

02:01.350 --> 02:06.580
And let's make transition back to our work and let's select the back transition.

02:06.580 --> 02:08.060
Let's go over to Inspector.

02:08.100 --> 02:08.980
Let's uncheck.

02:08.980 --> 02:12.740
This has exit time as well as transition duration to zero.

02:12.860 --> 02:14.260
And we're going to scroll down.

02:14.260 --> 02:16.460
And now we're going to click on this plus icon.

02:16.460 --> 02:19.380
And we will choose if attack is false.

02:19.380 --> 02:23.220
So if attack is false then it's going to play that animation clip.

02:23.420 --> 02:30.220
Uh so for this moment I'm going to make my anime work speed a little bit, a little bit less.

02:30.220 --> 02:33.340
So I'm going to select my animator game object in the hierarchy.

02:33.500 --> 02:38.100
Let's go over to Inspector then Animator Script, and I'm going to make the workspace.

02:38.100 --> 02:43.420
So uh, to something like 0.1 I'm just doing for testing purposes only.

02:43.580 --> 02:49.940
And if we go ahead and then play, but click on this play button in the top in order to play our game

02:49.940 --> 02:56.980
and try to trigger the sorry, try to set this attack parameter manually to true or false basically

02:56.980 --> 02:58.500
means uncheck or check.

02:58.540 --> 03:01.100
You will see the transition going to happen.

03:01.100 --> 03:07.170
So if I move over to my animator tab and if I just manually set it to true basically checked, we can

03:07.170 --> 03:12.850
see enemy to attack animation is playing over again and again.

03:13.010 --> 03:19.770
And if I set it to uncheck basically false, we can see by now it's playing that work animation clip.

03:19.770 --> 03:22.730
So we need to set this parameter through our code.

03:22.730 --> 03:24.210
So let's get out of play mode.

03:24.210 --> 03:28.050
And let's make also transition to this enemy heart.

03:28.050 --> 03:31.930
And we're gonna make this animation a clip from any state.

03:32.050 --> 03:39.090
Uh, no matter if we are working or applying attack animation clip, if we take damage, then this enemy

03:39.130 --> 03:42.850
to game object need to play the heart animation clip right away.

03:43.010 --> 03:46.490
So that's why we're gonna make the transition from any state.

03:46.690 --> 03:52.690
So let's right click on this any state and let's make transition to our enemy heart to and let's select

03:52.690 --> 03:53.610
this transition.

03:53.610 --> 03:55.170
Let's go over to Inspector.

03:55.330 --> 03:57.650
And then we're gonna uncheck this as exit time.

03:57.650 --> 04:04.000
Because as soon as we're gonna take damage from this player game object, and then this animated game

04:04.040 --> 04:07.480
object need to play the heart animation clip right away.

04:07.640 --> 04:10.200
So that's why we uncheck the has exit time.

04:10.200 --> 04:13.240
And let's see this transition duration to zero.

04:13.440 --> 04:16.920
And if we scroll down we need to choose a condition.

04:17.040 --> 04:19.800
So let's choose a trigger condition for it.

04:19.800 --> 04:22.560
So let's move over to animator tab parameters.

04:22.560 --> 04:24.240
Let's click on this plus icon.

04:24.240 --> 04:26.000
And we're going to choose a trigger.

04:26.000 --> 04:29.920
And we can call this trigger to something like Heart or Damage.

04:29.920 --> 04:31.200
So let's call it heart.

04:31.240 --> 04:32.720
Let's go over to Inspector.

04:32.720 --> 04:34.840
And we're going to click on this plus icon.

04:34.840 --> 04:40.080
And we're going to choose that heart trigger heart parameter or that heart condition.

04:40.520 --> 04:44.600
So if we just trigger this parameter then this heart to animation clip.

04:44.600 --> 04:48.560
Just gonna play of this animator game object right away.

04:48.560 --> 04:54.320
So we also need to make transition to this enemy to work as well as enemy to attack.

04:54.320 --> 04:58.440
Or we will stuck forever into this heart animation clip.

04:58.440 --> 05:00.760
So let's right click on this animator heart.

05:00.760 --> 05:06.110
And we're going to make transition to animated work as well as let's right click on it and let's make

05:06.150 --> 05:07.990
transition to enemy to attack.

05:08.190 --> 05:10.470
And now we're going to select this transition.

05:10.750 --> 05:14.390
So let's select from this heart to our idol first.

05:14.390 --> 05:16.150
And then go over to Inspector.

05:16.150 --> 05:18.110
And we're going to leave the exit time.

05:18.590 --> 05:21.150
This has exit time as well as exit time.

05:21.150 --> 05:22.390
We will choose one.

05:22.390 --> 05:22.830
Why.

05:23.030 --> 05:28.510
Because we want to play the heart animation clip of this enemy two game object 100%.

05:28.510 --> 05:31.950
And after that we want to play the work animation clip.

05:31.950 --> 05:35.950
So that's why we just leave the has exit time and transition duration.

05:35.950 --> 05:37.350
We're going to set it to zero.

05:37.350 --> 05:40.230
And if we scroll down we can choose a condition.

05:40.230 --> 05:43.550
And let's suppose you don't choose a any condition.

05:43.550 --> 05:49.710
Then it's automatically gonna play the work animation clip of this enemy to game object.

05:49.710 --> 05:58.470
So since we have a condition which is are at attack or let's, let's, uh, let's skip that.

05:58.510 --> 06:03.820
We're not gonna choose any condition from this hard to work animation clip.

06:03.820 --> 06:06.700
So basically it's going to play the heart animation clip.

06:06.700 --> 06:13.500
And once it's played 100%, then it's gonna move over to this work animation clip of this anime two

06:13.540 --> 06:17.660
game object automatically if we don't choose any condition.

06:17.660 --> 06:23.380
But for in this attack condition from this anime to heart to our attack.

06:23.820 --> 06:25.460
So let's select that transition.

06:25.460 --> 06:27.620
We're gonna choose a condition for it.

06:27.620 --> 06:29.700
So let's go over to Inspector first.

06:29.700 --> 06:32.740
And we're going to leave this as time and exit time.

06:32.740 --> 06:35.020
We're going to choose one basically means 100%.

06:35.020 --> 06:38.660
We're gonna play and we will set transition duration to zero.

06:38.660 --> 06:42.060
And if we scroll down we need to choose a condition.

06:42.060 --> 06:44.700
So for this we're gonna choose this plus icon.

06:44.700 --> 06:46.100
Let's click on this plus icon.

06:46.100 --> 06:48.700
And we will check if attack is true.

06:48.700 --> 06:55.020
And we do know that if we set this attack parameter is true, it's gonna play this attack to animation

06:55.020 --> 06:56.700
clip instead of the work.

06:56.700 --> 06:59.260
So that's why we have chosen that condition.

06:59.260 --> 07:05.330
And if you don't choose any condition as well, if you just remove that and it's gonna move over to

07:05.370 --> 07:06.330
this attack.

07:06.330 --> 07:07.130
Animation clip.

07:07.170 --> 07:12.490
Enemy to attack animation clip automatically depending upon where player is.

07:12.490 --> 07:17.530
If the player is inside attack range, then it's gonna play the attack animation clip.

07:17.530 --> 07:22.490
If it's not, then it's gonna play the animation clip so you can choose the condition.

07:22.490 --> 07:23.770
It's totally up to you.

07:23.770 --> 07:26.410
If you don't want then you can just remove it.

07:26.610 --> 07:29.650
But for attack I just did it.

07:29.650 --> 07:32.610
You can just skip that as well if you want.

07:32.810 --> 07:36.050
And now we need to make transition enemy to that.

07:36.050 --> 07:42.650
But before we do, let's try to trigger this hard parameter manually if it's working or not.

07:42.650 --> 07:44.850
So basically we just want to check.

07:44.850 --> 07:48.850
So let's click on this play button in the top in order to play our game.

07:48.850 --> 07:51.650
And let's trigger this hard parameter manually.

07:51.850 --> 07:57.490
If we trigger it it's going to play the hard animation clip of this enemy to game object instead of

07:57.530 --> 07:59.690
work or attack right away.

07:59.850 --> 08:06.640
So if I try to trigger this parameter, as you can see, as soon as we playing, this enemy just plays

08:06.640 --> 08:08.520
that heart animation clip.

08:08.520 --> 08:14.400
And once it's played 100%, it just move it over to this work animation clip automatically.

08:14.560 --> 08:18.880
But if the player in attack range, then it's going to play this animation clip.

08:18.880 --> 08:26.120
So if I take my player and then move it over here, something like that, and then move over to animator

08:26.120 --> 08:29.040
tab and select this animator GameObject in the hierarchy.

08:29.200 --> 08:36.200
And if I set this attack parameter to true, now it's playing the attack animation clip instead of the

08:36.240 --> 08:36.560
work.

08:36.560 --> 08:36.960
Why?

08:37.120 --> 08:42.000
Because this player inside this attack range radius as you can notice.

08:42.000 --> 08:42.960
So that's why.

08:43.000 --> 08:44.640
So I hope you get the idea.

08:44.640 --> 08:46.600
And now we're gonna get out of play mode.

08:46.600 --> 08:51.800
And what we will do, we need to make transition to this enemy to that uh, by now.

08:52.280 --> 08:54.480
And we're going to make it from any state.

08:54.480 --> 09:00.840
So let's right click on this any state and let's make transition to enemy to that animation clip.

09:00.840 --> 09:05.350
Why we made from this any state, no matter what state we are in.

09:05.350 --> 09:10.470
Basically, if the player is walking, taking, taking damage from this enemy came up.

09:10.670 --> 09:16.790
Sorry from this player game object or this enemy to game objects playing the attack to animation clip.

09:16.790 --> 09:22.310
If it's lose all of his health, then it's need to play the death animation clip of this enemy to game

09:22.350 --> 09:23.950
object right away.

09:23.990 --> 09:27.350
No matter what we doing, like playing attack or walking.

09:27.350 --> 09:31.110
So that's why we just making transition from any state.

09:31.110 --> 09:32.870
And we're gonna select this transition.

09:32.910 --> 09:34.670
Let's go over to Inspector.

09:34.670 --> 09:37.790
And now we're going to leave the has exit time and exit time.

09:37.790 --> 09:39.350
We're going to choose one.

09:39.510 --> 09:46.510
And because we want to play the death animation clip of this enemy to game object are 100%.

09:46.510 --> 09:47.310
So that's why.

09:47.470 --> 09:50.150
And transition duration we're gonna set it to zero.

09:50.310 --> 09:57.350
And if we scroll down we're going to choose a second trigger or a another trigger parameter for this.

09:57.350 --> 09:58.790
So let's create that.

09:58.790 --> 10:01.750
So we will move over to animator tab then parameters.

10:01.750 --> 10:03.510
Let's click on this plus icon.

10:03.510 --> 10:08.100
And we're going to choose a trigger and we have to name the trigger or the condition.

10:08.100 --> 10:10.140
So let's call it something like death.

10:10.380 --> 10:15.140
And uh, and we're going to choose this trigger parameter or that condition.

10:15.140 --> 10:20.340
So let's go over to Inspector then scroll down to the bottom condition and let's click on this plus

10:20.340 --> 10:20.860
icon.

10:20.860 --> 10:26.540
And now we're going to choose that death trigger, that trigger condition or that parameter.

10:26.540 --> 10:32.860
So now if we go ahead and then play hit this play button in the top and manually try to trigger this

10:32.860 --> 10:33.940
death parameter.

10:33.940 --> 10:37.900
You will see the death animation just going to play right away.

10:38.060 --> 10:39.180
So let's have a look.

10:39.180 --> 10:45.460
So if I trigger this death parameter, as you can see, as soon as we trigger it we just play that.

10:45.460 --> 10:52.380
And we're not making from uh, making transition from this enemy to, to our attack heart or a work.

10:52.380 --> 10:52.780
Why?

10:52.980 --> 10:58.340
Because once it loses all of his health, then it's need to be destroyed.

10:58.340 --> 11:05.250
So that's why we're not making this, uh, not making any transition from this enemy to that animation

11:05.250 --> 11:07.370
clip to heart attack or work.

11:07.370 --> 11:08.890
So that is the reason.

11:08.890 --> 11:10.530
So I'm going to get out of play mode.

11:10.530 --> 11:15.730
So I hope you get the idea that how you can make transition between this animation clip.

11:15.730 --> 11:20.970
So you need to choose some certain condition and some certain condition.

11:20.970 --> 11:22.690
So you can just make that.

11:23.970 --> 11:28.170
You can make the transition between this animation clip.

11:28.170 --> 11:33.090
And we need to set this parameter through our code depending upon where player is.

11:33.090 --> 11:39.850
If the player in attack range attack range radius are, then this enemy need to play this animation

11:39.850 --> 11:46.890
clip which says enemy to attack and if the player is not are not inside of it then it's need to play

11:46.890 --> 11:47.450
the work.

11:47.450 --> 11:53.730
So we need to set this parameter, this attack heart and the death through our scripting of this enemy

11:53.770 --> 11:55.090
to game object.

11:55.090 --> 12:01.250
So I hope you get the idea that how you can do it and make sure you press down Ctrl s on your keyboard

12:01.250 --> 12:03.370
in order to save your project.

12:03.370 --> 12:05.650
So I hope you get the idea of it.
