WEBVTT

00:00.000 --> 00:00.420
Hello guys.

00:00.420 --> 00:01.350
Welcome to the video.

00:01.350 --> 00:04.560
In this one I want to show you how to make camera transitions.

00:04.560 --> 00:08.040
It's going to work in a very similar way to what we have in Celeste.

00:08.040 --> 00:15.780
And to show you that we actually need a bigger level, let's go ahead and make a folder inside of a

00:15.780 --> 00:16.680
prefab folder.

00:16.680 --> 00:18.510
We're going to need folder for camera.

00:19.050 --> 00:20.250
I'm going to do camera.

00:21.070 --> 00:25.750
Then I'm going to take these two and drag them into the camera's folder like that.

00:26.230 --> 00:28.480
Now let's go to asset scene.

00:28.480 --> 00:31.960
I'm going to take level three and I'm going to duplicate it.

00:32.470 --> 00:34.420
Let's make it as level four.

00:34.450 --> 00:38.800
Before I forget let me go to build profiles and drag it here.

00:40.300 --> 00:40.780
I'm sorry.

00:40.780 --> 00:43.300
Sin list and drag it here.

00:43.300 --> 00:44.290
Nice.

00:45.670 --> 00:48.190
Now we're going to close this and we're going to go to level four.

00:48.190 --> 00:49.300
Save it.

00:49.780 --> 00:54.520
So over here I need to make a level that would have two screens.

00:54.520 --> 01:01.060
So for example one screen over here and one screen of the level here I'm going to do it in a time lapse.

01:01.060 --> 01:01.900
Nothing new.

01:01.900 --> 01:05.350
Just a couple of platforms and a couple of places to jump.

01:05.350 --> 01:05.980
All right.

01:11.440 --> 01:15.370
Now, look, I've created part of the level I think I like the first half.

01:15.370 --> 01:19.390
Now I need to know approximate size of the second part of the level.

01:19.390 --> 01:21.190
So I'm going to go to cameras.

01:21.190 --> 01:24.640
I'm going to drag this level camera over here.

01:26.200 --> 01:29.470
And also you need to drag camera manager and keep it here.

01:29.500 --> 01:34.480
I'm going to delete the main camera because we have camera manager now and level camera is over here.

01:34.480 --> 01:38.890
And I'm going to duplicate the level camera because we're going to need to do transition from one camera

01:38.890 --> 01:39.610
to another.

01:39.610 --> 01:42.640
So let's duplicate it and let's move it.

01:43.120 --> 01:43.540
Um.

01:44.340 --> 01:47.220
To the right over here like that.

01:47.490 --> 01:51.270
So now we have the area in which we supposed to have the level.

01:51.270 --> 01:52.260
This is the area.

01:52.260 --> 01:53.700
All right, I think I like it.

01:53.700 --> 01:56.610
Now let me think of some obstacles here.

01:57.310 --> 01:57.520
Here.

01:57.520 --> 02:01.750
As you can see, I like to do wall jumps, so that's why I'm doing it that way.

02:02.200 --> 02:04.660
Uh, let me see the waypoints.

02:04.780 --> 02:05.110
Yeah.

02:05.110 --> 02:06.160
Looks good to me.

02:07.870 --> 02:08.410
Let's move.

02:08.440 --> 02:09.940
Checkpoint over here.

02:10.180 --> 02:15.100
And yes, this should be good.

02:15.130 --> 02:20.470
Now we need to take the finish point, place it here and some fruits should be here.

02:22.230 --> 02:24.630
All right, so this is good.

02:24.630 --> 02:26.250
I like what I have here.

02:26.250 --> 02:28.980
Now, how do we make transition between cameras?

02:28.980 --> 02:31.860
Actually that is super, super super simple.

02:31.860 --> 02:36.840
Let me just take these fruits and put them into a parent because I don't like the mess in the hierarchy.

02:36.840 --> 02:38.040
Fruits.

02:38.580 --> 02:41.160
Take these, drag them into fruits.

02:41.580 --> 02:41.910
All right.

02:41.940 --> 02:44.610
Now if you want you can disable all fruits together.

02:45.270 --> 02:46.800
Um, back to the camera.

02:46.800 --> 02:52.380
On each camera we have this cinemachine limits which have trigger Collider.

02:52.380 --> 02:59.790
And on enter to this collider, we can enable the camera and make it follow the player.

02:59.790 --> 03:01.500
And that's what we're going to do.

03:02.700 --> 03:04.800
We have a level camera object.

03:04.800 --> 03:06.630
We just need a script for this.

03:07.110 --> 03:09.930
And the script let's do.

03:14.020 --> 03:14.650
Uh, script.

03:14.650 --> 03:16.360
Come on, make a script, boy.

03:17.370 --> 03:18.780
Level camera.

03:21.760 --> 03:24.970
And we also need level camera trigger.

03:26.830 --> 03:30.970
C sharp script level camera trigger.

03:32.160 --> 03:35.520
Okay, now let's take the limits over here.

03:37.790 --> 03:43.730
Pull the trigger on and let's take the level camera and put the level camera on.

03:43.790 --> 03:49.400
Now for the level camera we need to get access to this component over here.

03:49.670 --> 03:50.030
Right.

03:50.030 --> 03:51.260
That's what we need to do.

03:51.770 --> 03:58.250
And from this script over here, when player enters the trigger, we need to call method from a main

03:58.250 --> 04:03.200
level camera script and ask it to follow the player.

04:03.530 --> 04:05.600
So let's go to level camera first.

04:07.200 --> 04:11.190
We're going to make private cinemachine.

04:12.210 --> 04:13.830
The new machine.

04:15.510 --> 04:16.800
Wait, how do we do that?

04:17.500 --> 04:19.540
Cinemachine virtual camera.

04:19.840 --> 04:20.620
All right.

04:20.740 --> 04:22.270
Cinemachine.

04:27.620 --> 04:28.010
Okay.

04:28.010 --> 04:30.020
We can see it was changed.

04:30.020 --> 04:33.050
We just need to use Cinemachine camera instead.

04:33.050 --> 04:34.220
Okay, let's try that.

04:35.190 --> 04:36.210
Okay, good.

04:36.210 --> 04:41.100
Then in the week we're going to do Cinemachine equals to get component of Cinemachine camera.

04:41.100 --> 04:42.900
But in.

04:43.560 --> 04:44.610
Children.

04:45.300 --> 04:46.080
Okay, good.

04:46.110 --> 04:48.570
Now first I want to be sure it is working.

04:48.570 --> 04:50.340
So I'm just going to go to unity.

04:53.720 --> 04:57.260
Gonna enable debug mode and I'm going to go to play mode.

05:00.380 --> 05:01.130
It did work.

05:01.130 --> 05:01.400
Okay.

05:01.400 --> 05:03.020
We have reference to this one.

05:03.020 --> 05:04.100
Very nice.

05:04.100 --> 05:05.990
Now let's go back to scripts.

05:06.530 --> 05:11.960
And we're going to need a method that would make, uh the camera follow the transform.

05:11.960 --> 05:13.610
So I'm going to do public void.

05:16.790 --> 05:20.870
Cameras are maybe set new target.

05:20.870 --> 05:23.870
We're going to pass transform new target.

05:23.870 --> 05:29.120
And then inside we're going to do Cinemachine follow equals to new target.

05:29.150 --> 05:32.060
Simple as that I like it I like it a lot.

05:32.060 --> 05:34.580
Now let's go to the cinema scene.

05:34.580 --> 05:37.400
I mean level camera trigger over here.

05:37.400 --> 05:41.540
We want to get component of level camera level camera.

05:41.930 --> 05:47.900
Then we want to do on trigger enter to De same as we did with any other things.

05:47.900 --> 05:50.930
I'm just going to use component to detect the player.

05:50.930 --> 05:57.110
So let me go to the image trigger I'm just going to copy this over here.

05:57.440 --> 05:59.480
Go back paste it in.

05:59.480 --> 06:08.840
And instead of damaging and knockback I'm going to do level camera new set new target player dot transform.

06:08.840 --> 06:09.920
Just like that.

06:09.920 --> 06:14.540
Also would be nice to disable the camera I think just in case.

06:14.540 --> 06:18.560
So let's go to level camera over here and let's do.

06:22.390 --> 06:23.620
Public void.

06:26.100 --> 06:29.910
Enable camera, we're going to do bool enable.

06:29.910 --> 06:31.230
That's what we're going to pass.

06:31.230 --> 06:36.210
And inside we're going to do Cinemachine GameObject set active to enable.

06:36.210 --> 06:36.990
All right.

06:36.990 --> 06:41.340
We're just going to need to use it on trigger over here.

06:41.340 --> 06:44.310
When we enter the trigger we're going to do.

06:47.010 --> 06:54.600
Level camera enable camera equals to true because we want to enable the camera and then set follow and

06:54.600 --> 06:59.850
on trigger exit to D we're going to do the same thing man.

06:59.850 --> 07:01.860
Now I think I should use tags honestly.

07:01.860 --> 07:06.390
Why not just just make sure you don't make a mistake with the tag and it will be fine.

07:06.390 --> 07:09.360
Well both ways are working fine, so it's okay.

07:09.780 --> 07:11.940
So if player not equals to null, then we're gonna.

07:12.700 --> 07:15.760
And disable the camera when we exit the trigger.

07:15.760 --> 07:18.460
And probably that's just it.

07:18.460 --> 07:19.900
We don't need to do anything else.

07:21.010 --> 07:21.700
Okay.

07:21.700 --> 07:22.810
Very good.

07:22.840 --> 07:24.310
Now let's save this.

07:24.310 --> 07:28.630
Let's go back to unity and we're going to take level camera.

07:28.930 --> 07:33.130
We're going to go to normal mode and we're going to apply overrides.

07:33.520 --> 07:34.090
Nice.

07:34.090 --> 07:37.900
Now this will be applied to any other camera you have in the game.

07:39.190 --> 07:40.390
And we have two.

07:42.920 --> 07:45.860
And by default, actually, I think we should disable the camera.

07:45.860 --> 07:47.810
So let's go to.

07:47.840 --> 07:50.240
Let's just disable the camera like that.

07:54.560 --> 07:55.010
Yeah.

07:55.040 --> 07:55.820
Good.

07:55.820 --> 07:59.450
In case you forget to disable the camera, we can go over here.

07:59.450 --> 08:02.000
And in the wake, we can do enable camera.

08:02.860 --> 08:09.250
Uh, pulse is going to disable the camera on the awake, but player will enter the trigger and it will

08:09.250 --> 08:12.100
enable the camera where your player is.

08:12.130 --> 08:13.240
Now, let me try that.

08:13.240 --> 08:16.210
I'm going to place my player over here on the edge.

08:17.730 --> 08:20.490
And I'm going to try to walk to another room.

08:21.030 --> 08:22.590
So I'm standing there.

08:23.390 --> 08:23.660
Wait.

08:23.660 --> 08:24.320
What is it?

08:36.290 --> 08:39.710
Couldn't get it because I did disable the object.

08:39.710 --> 08:42.710
Okay, my bad object is disabled.

08:42.710 --> 08:43.820
We're not getting component.

08:43.820 --> 08:45.920
Let's type true over here.

08:46.430 --> 08:48.830
Let's save it and let's go back.

08:53.450 --> 08:54.200
Okay now.

08:54.200 --> 08:54.830
It's fine.

08:54.830 --> 08:55.790
Now it's not.

08:55.790 --> 08:56.660
What is it?

08:57.640 --> 08:59.500
Uh, we need to be sure it's working.

09:03.380 --> 09:06.830
Object reference not set is an instance of an object.

09:07.730 --> 09:08.810
Why not?

09:14.800 --> 09:16.540
Oh, I am so sorry.

09:16.540 --> 09:19.750
I forgot to get the component awake.

09:19.750 --> 09:23.440
Level camera equals to get component in parent.

09:24.300 --> 09:25.260
Off level camera.

09:25.290 --> 09:26.250
Okay, nice.

09:26.250 --> 09:30.300
Let's save this and let's go back to unity again.

09:33.100 --> 09:34.510
Okay, no more errors.

09:34.510 --> 09:35.080
We can see.

09:35.110 --> 09:36.310
Camera is fine.

09:36.310 --> 09:37.870
We can see entire level.

09:37.990 --> 09:44.830
I'm just going to go ahead and try to switch the level and boom we are on the new camera.

09:45.280 --> 09:46.210
Very cool.

09:46.240 --> 09:47.980
There is one issue though.

09:47.980 --> 09:55.690
It was kind of fast and although I kind of like it, honestly, I kinda like how it works, but it's

09:55.690 --> 09:58.510
better to do some sort of blend between the cameras.

09:58.510 --> 10:02.080
And it was supposed to work automatically, but I don't see the blend.

10:02.440 --> 10:03.820
Let me try to fix it.

10:17.610 --> 10:18.540
All right.

10:19.490 --> 10:21.470
All right, I see what the problem is.

10:21.470 --> 10:22.100
Um.

10:23.530 --> 10:24.520
Over here.

10:24.520 --> 10:29.770
I have Collider here and second limit is over here.

10:29.770 --> 10:32.950
So we have like lots of space between them.

10:32.950 --> 10:35.230
And I think that's not really good.

10:35.230 --> 10:39.940
So let's take the limits over here and maybe let's increase them.

10:42.790 --> 10:43.570
Like that.

10:43.600 --> 10:45.190
Now let me try again.

10:48.900 --> 10:51.270
Yeah, now it is smooth, I like it.

10:51.270 --> 10:56.400
So what you can see here is a blend transition between cameras and.

10:59.120 --> 11:01.970
And you can adjust it.

11:01.970 --> 11:03.500
Sorry, I was busy killing enemy.

11:03.500 --> 11:06.740
You can adjust it over here by using default blend.

11:06.740 --> 11:11.300
You just change the default blend or you change the duration of a blend.

11:11.300 --> 11:15.800
For example, you can do 0.5, then it will be faster like that.

11:15.800 --> 11:18.320
Or you can do five seconds.

11:18.320 --> 11:20.450
Then it will be longer like that.

11:20.450 --> 11:25.520
For example, when you want to present a new level, this is a valid option.

11:25.520 --> 11:26.600
I kind of like it.

11:29.620 --> 11:34.090
Although I don't like what is happening there with, uh, uh, walls.

11:34.090 --> 11:35.410
You can see that, right?

11:35.950 --> 11:37.600
Let me see it closer.

11:43.040 --> 11:47.600
I sort of find it was not fine only in the small window, but like that, I think it's okay.

11:47.960 --> 11:50.060
Uh, let me try shorter blend.

11:50.060 --> 11:54.320
And you can experiment with these, try on different things.

11:54.320 --> 11:54.680
Maybe.

11:54.680 --> 11:55.880
Let's do cut.

11:56.930 --> 11:58.310
Then it will be like that.

11:59.680 --> 12:01.900
Let's do hard in.

12:05.310 --> 12:06.510
Let's do hard out.

12:08.270 --> 12:08.600
Yeah.

12:08.600 --> 12:11.510
So again, personal preference.

12:13.100 --> 12:16.250
You could do custom blends or you could do linear.

12:16.370 --> 12:18.770
It's always up to your decision.

12:18.770 --> 12:19.970
Don't worry about that glitch.

12:19.970 --> 12:22.100
It is fine when you make a full screen.

12:25.390 --> 12:27.460
So we have a nice camera.

12:27.460 --> 12:33.340
Also, something about this you can, um, set up camera differently.

12:34.840 --> 12:36.130
For different areas.

12:36.130 --> 12:39.070
What I mean by that, you have full control of the camera.

12:39.070 --> 12:46.270
So you can go to this camera over here and change lens to something like four, for example.

12:46.270 --> 12:51.910
And then when you go to the next room, your camera will not only change the view, but also it will

12:51.910 --> 12:53.470
change the zoom like that.

12:53.470 --> 12:57.760
And you can present a new challenge to the player where he cannot see much.

12:57.760 --> 12:58.960
For example.

12:58.960 --> 12:59.410
Yeah.

13:01.510 --> 13:03.460
Well, that's very good.

13:03.880 --> 13:06.910
I like it, I'm going to change it back to ten.

13:07.270 --> 13:08.380
That's how I like it.

13:08.380 --> 13:10.900
And this is how you set up transition between cameras.

13:10.900 --> 13:13.840
Now we have bigger level with different cameras.

13:13.840 --> 13:20.830
And the last thing we need to do before I forgot we need to go to other levels like scene like level

13:20.830 --> 13:21.190
two.

13:21.190 --> 13:22.540
Let me save changes.

13:22.540 --> 13:25.930
And over here we need to add cameras from prefab.

13:25.930 --> 13:26.920
So camera.

13:28.140 --> 13:28.860
Let's take these two.

13:28.860 --> 13:29.940
Drag them here.

13:29.940 --> 13:31.830
Let's delete main camera.

13:31.920 --> 13:33.990
And these two can be over here.

13:33.990 --> 13:38.730
And you just need to take the level camera and adjust it to the limits you have here.

13:39.150 --> 13:41.850
So I think I want player to see.

13:43.390 --> 13:44.680
Maybe this much.

13:46.000 --> 13:49.120
Okay, now let's go to asset scene level three.

13:49.510 --> 13:52.090
Save going to go to prefab.

13:52.860 --> 13:53.640
Take the cameras.

13:53.640 --> 13:54.870
Drag them here.

13:55.820 --> 14:02.630
Delete main camera and for the level camera, just place the limits as you like.

14:03.680 --> 14:06.380
Okay, I think I like it.

14:07.690 --> 14:09.580
I'll see you in the next video.

14:09.580 --> 14:11.920
Then let's save this and let's go.
