Hello, guys.
There is something else we need to do before we finally build level parts.
We need to restrict movement of the camera, because at the moment, our camera follows the player on
x and y axis and we somehow need to block y axis movement.
Look at this.
If I jump on the high platforms that are kind of upstairs, you can see my camera went up and now I
don't see what is below.
And that could go endlessly.
And in the end we would lose view of our town or, you know, just basically it's not even coming back
down.
If I need to.
Look, I'm jumping low and I cannot see my character.
I even died because of the dead zone.
So this is what we're going to do in this video, how we can do that.
If you take a polygon collider and you give it to cinema machine, Cinema machine will move inside of
that collider.
So that's how we do it.
We go to Cinema Machine, add ext confine there to DX and now we can see it says about in shape is required.
So this what we need to do.
And for this one we must use Polygon Collider and we need to make sure this collider moving together
with a camera.
So what I want to do here is to take background number five because it moves together with a camera
with the same speed and put collider on this object and then use this object with this collider is a
confined air to blow camera movements.
All right, so let's click add component Polygon Collider Right now we need to change the size and yours
might look different.
Yours might look like a polygon, but it doesn't matter.
You just click point.
So here, make sure it size is four.
Then let's click edit Collider and just make it, you know, like a size of a town, let's say.
So a bit above the city line and just below the camera somewhere here.
You don't need to copy it.
Exactly.
Just supposed to be bigger than the camera itself.
What I mean by that is this is the collider of the camera, the white one.
And this polygon collider should be bigger than that.
So camera can move inside of this collider.
And let's find some it's set the size.
So I think this is okay.
Just above the skyline, four bit and below the camera.
It's okay.
Now I want to change these numbers because I don't like numbers like this.
I want them to be even.
So what I'm going to do here is to make it -0.5 here as well.
Same for positive value.
For the Y.
This one looks like three.
This one looks like minus two.
Minus two and three.
Okay.
That's good.
Now, let's make sure we check is trigger so it won't collide with objects.
We can cover this select Sigma machine and drag collider of the background.
Number five over here.
Boom!
Now, let's click this oversize window and then click again.
Because sometimes, for some reason, Collider is not updated.
What I mean by that, Look, if I change this collider here to something like this and I choose my cinema
machine, it's not updated, but if I'll click over size window a couple of times, then it will be
updated.
So that's what we need to do.
Now let's let me revert the changes.
Yeah.
So here is the settings for Polygon Collider.
You can see it.
These are my numbers.
You're supposed to be kind of the same, but if it's a bit different, don't worry.
Just make sure this collider is bigger than this white box of the camera and gives.
All right, now let's go and see what it gives us.
Now, if we try this, we can see that camera cannot exceed the collider we just created.
Let me find it.
Here is the cinema machine.
This is the collider and this is the camera itself right here.
And it cannot exceed the collider, which is good, which is what we need.
Now, I want to adjust camera behavior for a bit so it will look a bit better when he moves down.
Let's go to body of the cinema machine over here, buddy, and what we're going to do here.
Increasing the dead zone on the height.
And increase in soft zone on the height just like that, and then going to move bias on the Y.
Do something like this.
Let me increase the zone of the so I can see it because it's not really visible.
Just point one so we can see the box.
Right.
This the one?
Straight point five.
Let's decrease the height of the dead zone, but increase height of the south zone to something like
this so camera can move above.
But if we going down, Camara should move down really fast.
Let's try this.
I'm going to adjust my level parts to something different.
When we're going up, it moves up slowly.
But if I go down, it moves down fast.
Cool.
You can see the difference, right?
Look how it moves up.
Very smoothly.
And if I'm falling.
Boom.
Cool.
So this is the settings of this machine container.
This is the size of the collider.
And this is the settings of the body of cinema machine.
See in the next video.