WEBVTT

00:00.080 --> 00:01.720
Let's make our camera shake.

00:01.720 --> 00:03.400
So we're going to move over to hierarchy.

00:03.400 --> 00:04.840
Let's go to Camera Parent.

00:04.840 --> 00:07.520
And we have the main camera as you can see.

00:07.520 --> 00:10.160
So we created a parent game object first.

00:10.160 --> 00:16.000
And then we just made our main camera as a child of that camera parent because we're going to create

00:16.000 --> 00:17.920
animation in this main camera.

00:17.920 --> 00:22.400
So that's why we just create a created an empty parent game object first.

00:22.400 --> 00:27.360
And then we just made that a main camera child of that game object, as you can see.

00:27.360 --> 00:29.120
So you can do that.

00:29.360 --> 00:35.280
Uh, so if you just little bit or worry it, then you can just, uh, check the first and the second

00:35.280 --> 00:41.640
lecture, basically where I explained it about this camera parent and made that follow script, uh,

00:41.640 --> 00:43.520
so you can go and check that.

00:43.880 --> 00:46.480
So now what we're going to do, we're going to make the animation.

00:46.480 --> 00:51.160
So let's select the main camera in our hierarchy underneath our camera parent game object.

00:51.200 --> 00:52.840
Let's go to animation tab.

00:52.840 --> 00:56.840
And let's click on this create button in order to create our animation.

00:56.840 --> 00:58.880
So before we create let me explain.

00:58.880 --> 01:01.580
We're going to have to animation of this main camera.

01:01.620 --> 01:06.860
First we're going to have the ideal one or basically this camera just gonna not gonna shake anything

01:06.860 --> 01:07.420
like that.

01:07.460 --> 01:08.780
It's not gonna do that.

01:08.780 --> 01:12.220
And the second animation clip just gonna be the shake one.

01:12.220 --> 01:13.780
So we're gonna have two animation.

01:13.780 --> 01:17.900
One will be the normal one and another will be the camera shake one.

01:17.900 --> 01:18.980
So let's create that.

01:18.980 --> 01:20.740
So we're going to select our main camera.

01:20.740 --> 01:23.860
And let's click on this create button in animation tab.

01:23.860 --> 01:26.620
And let's go to assets and then animation folder.

01:26.620 --> 01:30.100
And let's move over to this stop animation sub folder.

01:30.100 --> 01:34.380
And we're going to create another sub folder for our main camera animation.

01:34.380 --> 01:36.940
So let's right click the new folder.

01:36.940 --> 01:41.860
And I'm gonna name this folder to something like camera underscore animation.

01:41.860 --> 01:47.620
So we're going to place all of the camera animation into this slot into this folder into this sub folder.

01:47.620 --> 01:48.420
So that's why.

01:48.460 --> 01:51.180
So let's open that up by double clicking on it.

01:51.180 --> 01:54.020
And we have to name the animation what we want to name it.

01:54.020 --> 01:58.910
So I'm going to call this one camera underscore shake animation because this is this cannot be shake

01:58.910 --> 01:59.110
one.

01:59.110 --> 02:01.430
So let's call it camera underscore shake.

02:01.470 --> 02:03.750
And after that let's click on the save button.

02:03.750 --> 02:05.870
And we need to make our animation.

02:05.870 --> 02:10.710
So let's move over to animation tab and make sure you select the main camera in the hierarchy.

02:10.710 --> 02:13.950
And then click on this red button in this animation tab.

02:14.150 --> 02:19.990
So what we're going to do now we're going to move our main camera to the right and to the up a little

02:20.030 --> 02:20.350
bit.

02:20.390 --> 02:22.350
And then we're going to move over to one frame.

02:22.350 --> 02:25.270
And we're going to set back the position to normal.

02:25.270 --> 02:31.070
So let's select our main camera and make sure you just click on this red button in animation tab in

02:31.070 --> 02:33.110
order to capture the animation.

02:33.110 --> 02:34.990
So we're going to select our main camera.

02:34.990 --> 02:37.310
Let's go to Inspector Transform.

02:37.310 --> 02:42.070
And in the X I'm going to move something like 0.10.1.

02:42.070 --> 02:46.230
And in the Y I'm going to put something like -0.1.

02:46.430 --> 02:51.990
And then I'm going to move over to one frame, and I'm going to set back this x position to zero as

02:51.990 --> 02:53.830
well as the y to zero.

02:53.830 --> 02:57.170
So if I just click on this play button we can see now the sake.

02:57.210 --> 02:59.490
And then I'm going to move over to one frame.

02:59.490 --> 03:03.130
Then I will set this x to something like -0.1.

03:03.130 --> 03:05.610
Basically I just want to flip the value.

03:05.610 --> 03:09.090
And in the y I'm going to choose, uh I'm gonna put 0.1.

03:09.250 --> 03:12.970
And after that we're going to move one more frame and then we're going to set back.

03:12.970 --> 03:19.410
So just basically drag this uh line in animation tab, you're going to see and we're going to set back

03:19.410 --> 03:21.770
to zero zero once again.

03:21.770 --> 03:26.250
And now if I just click on this play button we can see the animation by now.

03:26.250 --> 03:32.490
And if you just want to be more intense than, uh, you can just put bigger number in this slot to the

03:32.490 --> 03:37.450
X position, something like 0.2 and the Y you can simply put -0.2.

03:37.490 --> 03:38.770
It's totally up to you.

03:38.770 --> 03:45.890
But I'm gonna go with this point one and after, uh, basically, uh, making the animation, make sure

03:45.890 --> 03:49.770
you just hit that red button in order to capture the animation.

03:49.770 --> 03:51.450
Or you can just leave it like that.

03:51.450 --> 03:57.470
It's automatically gonna capture the animation, and we're gonna create one more animation of this main

03:57.470 --> 04:00.190
camera, which are not gonna be sick at all.

04:00.230 --> 04:02.310
Basically, that will be the normal one.

04:02.430 --> 04:03.310
So normal one.

04:03.310 --> 04:07.030
So we're going to select our main camera one more time and let's go to animation tab.

04:07.030 --> 04:08.350
And then click over here.

04:08.350 --> 04:10.790
And we're going to click on this Create New clip.

04:10.790 --> 04:12.910
And this animation will be the normal one.

04:12.910 --> 04:17.110
So we're going to call it something like camera underscore idle idle.

04:17.270 --> 04:18.550
So we're going to call it idle.

04:18.550 --> 04:20.870
And let's click on that save button.

04:20.870 --> 04:22.790
And we're going to click on this red button.

04:22.790 --> 04:26.030
And we don't want to capture at all anything like that.

04:26.030 --> 04:29.470
So after clicking the red button we're going to click on that to capture.

04:29.470 --> 04:32.830
And we're not doing at all anything as you can see.

04:33.230 --> 04:41.070
So if I moved over to project tab and then animation folder in assets then stop animation and then camera

04:41.070 --> 04:46.590
animation subfolder, we can see we have both the animation, we have the camera set as well as we have

04:46.590 --> 04:47.670
the camera idle.

04:47.790 --> 04:50.870
And I don't want this animation clip to be looped.

04:50.870 --> 04:54.000
So that's why I'm gonna select both of them by holding down shift.

04:54.040 --> 04:57.440
And let's go over to Inspector and I'm going to uncheck this loop time.

04:57.440 --> 05:00.800
So animation just not gonna be loop at all.

05:00.800 --> 05:06.200
So if I just click on this play button in the top you will see the shake animation will be played right

05:06.200 --> 05:07.400
after the game start.

05:07.440 --> 05:07.880
Why?

05:07.920 --> 05:10.840
Because that animation clip is the default one.

05:10.840 --> 05:12.960
So let's have a look before we set.

05:13.160 --> 05:17.320
So as you can see, camera is shaking as soon as the game started.

05:17.320 --> 05:24.240
And if we move over to animator and then select this main camera in the hierarchy, we can see we have

05:24.240 --> 05:27.520
the camera shake as well as the camera idle animation clip.

05:27.520 --> 05:30.680
So we need to make transition between this animation clip.

05:30.680 --> 05:37.240
But before we do, we want this camera idle animation clip to be the default one whenever the game starts.

05:37.240 --> 05:43.320
And once we take damage or our player game object gets destroyed, and then we're gonna play the, uh,

05:43.360 --> 05:46.440
you can simply say the camera shake animation clip.

05:46.440 --> 05:51.600
So let's get out of play mode, and let's select the main camera in the hierarchy and go over to animator

05:51.660 --> 05:52.100
tab.

05:52.100 --> 05:54.900
So we're going to set this camera idle to be the default one.

05:54.900 --> 05:56.220
So we're going to right click on it.

05:56.220 --> 05:59.100
And let's click on this set as layer Default start.

05:59.100 --> 06:04.460
And if we just click on this play button in the top you will see the camera idle animation clip will

06:04.460 --> 06:08.820
be played right after the game start and the camera will not shake anymore.

06:10.100 --> 06:15.860
So as you can see, as soon as the game started, the idle animation is now playing of this main camera.

06:15.860 --> 06:17.300
So let's get out of play mode.

06:17.300 --> 06:21.300
So we also need to make transition from this camera idle to camera shake.

06:21.340 --> 06:25.300
So let's right click on this camera idle and make transition to camera shake.

06:25.300 --> 06:27.020
And we're going to select this transition.

06:27.060 --> 06:28.180
Go over to Inspector.

06:28.180 --> 06:33.020
And we're going to untick this as exit time as well as we're going to set the transition duration to

06:33.020 --> 06:33.500
zero.

06:33.500 --> 06:38.780
Because as soon as we're going to take damage we're going to play this camera shake animation clip right

06:38.780 --> 06:39.220
away.

06:39.220 --> 06:40.780
We don't want any delay.

06:40.780 --> 06:46.180
So that's why we just untick has exit time as well as we set the transition duration to zero.

06:46.420 --> 06:52.270
So we need to choose a condition in which condition we want to play this camera shake animation clip.

06:52.270 --> 06:55.470
So condition slot we can see list is empty.

06:55.470 --> 06:59.950
So let's choose a condition in order to play this camera shake animation clip.

07:00.430 --> 07:06.550
So if we move over to animator in the left side we can see layers, and in the right side we can see

07:06.590 --> 07:07.430
parameters.

07:07.430 --> 07:09.110
So let's click on this plus icon.

07:09.110 --> 07:11.310
And we're going to choose this trigger in the bottom.

07:11.310 --> 07:15.270
And we're going to call this trigger to something like say uh sick.

07:15.470 --> 07:18.310
And now what we're going to do we're going to choose this condition.

07:18.310 --> 07:21.990
So let's go to Inspector and let's click on this plus icon in condition.

07:21.990 --> 07:23.670
And then we're going to choose this shake.

07:23.670 --> 07:29.310
So if I just click on this play button and try to trigger this check parameter manually in animator

07:29.350 --> 07:32.710
tab you will see the camera shake animation will be played.

07:32.710 --> 07:33.030
Why?

07:33.070 --> 07:34.910
Because we have chosen that condition.

07:34.910 --> 07:39.150
As you can see in Inspector, if we just check our trigger parameter.

07:39.150 --> 07:45.270
Basically if we check, uh, if we trigger this check parameter, this animation will be played right

07:45.270 --> 07:45.590
away.

07:45.590 --> 07:51.130
So if I just trigger, as you can see, as soon as we trigger the sick animation just split right away.

07:51.490 --> 07:58.210
And the problem is that we can see in animator tab, we are stuck in this camera shake animation clip

07:58.210 --> 07:59.090
forever.

07:59.090 --> 08:05.370
So we also need to play the idle animation clip after playing this camera shake animation clip 100%.

08:05.370 --> 08:10.290
So let's get out of play mode and let's right click on this camera shake and let's right click on it

08:10.290 --> 08:12.530
and make transition back to our idle.

08:12.930 --> 08:15.130
And now we're gonna choose the transition.

08:15.130 --> 08:16.330
Let's go to Inspector.

08:16.330 --> 08:19.050
And we're going to leave the has exit time and exit time.

08:19.050 --> 08:20.170
We're going to choose point.

08:20.330 --> 08:25.930
Sorry one one basically means we're gonna play the 100% animation clip of this shake.

08:25.930 --> 08:30.130
And then it will just gonna move over to this camera idle animation clip.

08:30.130 --> 08:32.810
And we're going to set the transition duration to zero.

08:32.810 --> 08:36.690
And if we scroll down we're not gonna choose any condition like that.

08:36.690 --> 08:43.410
So after playing the shake animation clip 100%, it's gonna play the camera idle animation clip right

08:43.410 --> 08:43.810
away.

08:45.170 --> 08:47.670
So if I just click on this play button, you will see.

08:49.270 --> 08:54.910
So if we just try to trigger this check parameter manually, you will see the camera check animation

08:54.910 --> 08:55.870
just going to play.

08:55.870 --> 09:01.830
And after playing this camera check animation clip, it's going to automatically play this camera idle

09:01.830 --> 09:02.870
animation clip.

09:02.870 --> 09:09.070
So if I just trigger this check parameter, as you can see, as soon as we trigger the check animation

09:09.070 --> 09:16.030
is playing and after playing 100% of animation, we can see the idle animation is now playing right

09:16.030 --> 09:16.590
away.

09:16.710 --> 09:19.390
So basically what we have to do, we need a.

09:19.910 --> 09:25.310
Basically if we select our main camera then go over to Inspector, we can see an animator component

09:25.310 --> 09:26.830
added to this main camera.

09:26.830 --> 09:31.430
Once we created this animation clip, basically this idle and the check one.

09:31.430 --> 09:37.150
So what we we basically need we need a reference of this animator component of this main camera.

09:37.150 --> 09:41.630
And then we can just trigger this check parameter through our code when we need.

09:41.630 --> 09:43.110
So I'm going to get out of play mode.

09:43.150 --> 09:49.120
I hope you get the idea that how you can do and if we select our camera pattern, we need to go to overrides.

09:49.120 --> 09:51.120
And then we're going to click on this apply all.

09:51.160 --> 09:51.560
Why?

09:51.600 --> 09:57.480
Because if we select our main camera in the hierarchy, we can see an animator component just added.

09:57.480 --> 10:02.840
Once we created this idle animation clip and the plus icon just becomes over here.

10:02.880 --> 10:05.840
Once this animator component added.

10:05.840 --> 10:11.680
So to get rid of that, basically to remove this plus icon, we need to move over to parent game object

10:11.680 --> 10:15.000
and then go over to overrides and then click on Apply All.

10:15.040 --> 10:18.680
As soon as we click now the plus icon is gone by now.

10:18.720 --> 10:24.040
Basically the changes we made in this camera parent game object in the hierarchy it just saved into

10:24.040 --> 10:27.680
this camera parent prefab game object as well.

10:27.680 --> 10:29.320
So basically that is the thing.

10:29.320 --> 10:31.520
So now we need to control this animator.

10:31.640 --> 10:37.080
Uh basically we need to set this shake parameter or we need to trigger this shake parameter.

10:37.080 --> 10:42.640
Once we take damage or once our player game object shoot on this enemy game object.

10:42.640 --> 10:45.360
So I'm going to press down Ctrl S to save my project.
