Welcome back, my fellow game developers.
In this video, what we've done is when we run our game,
you'll notice that as we are walking around,
we can go through all the room and the camera keeps following us.
And we do this using something called the Senate machine,
which is an extremely powerful tool that we are going to be implementing in this video.
So let's not waste any more time.
And let's get to creating these cinema.
Whoo, Look how cool that is now,
our game is much,
much nicer, feels much more professional, doesn't it?
When you have a camera following, Let's not waste any more time.
Let's get started.
Okay, so welcome back.
As you can see, I've created a sort of a,
kind of a map.
I think that just make this bigger me.
Please undock it, please.
Okay, there you go.
Open this up.
Okay, So this is the level that I created.
It's not much, but it works.
So as you can see,
I've added these couple of windows.
I hope you took the time to play around and understand how all of this works.
It took me around two to three hours of playing around,
making sure how everything looks and works and so on and so forth.
But this is the result that we have.
You can see I have a couple of, okay,
this is a mistake right here, for example,
you can see I've added a lot of black and the background.
You'll know why in just a bit.
I've made the walls right here that we cannot cross.
And I've made a couple of walls right here are
infused a couple of things together to create all of these.
So a couple of black walls,
a couple of natural causes,
scholar, even reddish walls and so on and so forth.
But the problem is if I make this window smaller, put it right here.
Phi 12, run the game.
So there you go.
If I run the game,
I can walk around and this whole map,
but I cannot see myself in the game view.
So imagine if we didn't have the scene view,
how would we be able to see ourselves?
And actually you can test it out.
You can maximize on play.
So when we run the game,
we will have a full-screen.
Okay, so now I want to walk away,
but there you go.
You cannot see anything.
Whereas the player, please, oh, there you go.
There we are. And now we try to shoot.
There is a bit of a delay,
a bit of a lag, but no worries about that.
Anyways, how are we going to fix that?
Well, what we can do is we can go ahead and attach
the camera to the doom player and make it a child.
And remember that the camera or a child always moves with the player.
So if I run the game right now,
there you go, problem fixed now we have a fall camp.
I hope you enjoyed the video and I'll see you in the next one.
I'm just getting.
And what we're going to do is use
a much more sophisticated technique in order to have our follicle.
So I'm just going to remove the main camera from the doom player,
child or parent, whatever you wanna call it, save that.
And then we are going to go into the window.
The package manager wait for Riunite to fetch our packages.
And any day now.
And in here we are going to go into
the Unity Registry and we are going to find this machine right here.
When you find some machines,
simply click on Install,
wait for it to install.
And when it's finished installing,
you can read more about.
So you can see right here it's a smart camera tool for passionate creators. Very nice.
So we'll have this extra tab appear,
which is the cinema machine.
And you can see that we can create a lot of things with cinema machine.
And the one that we really want is to create a virtual camera.
So let's do that.
We're going to create a virtual camera.
You'll see it right here.
The C and V Canvas just call it the virtual camera.
Hit Enter.
I'm going to set it right here next to the main camera.
And on the main camera,
I'm going to go into the inspector.
And immediately I can see right here that
we've added something called the cinema machine brain.
And if you still don't have this component on your camera,
make sure to add it because this is what will allow us to use the virtual camera.
So what is the virtual camera?
You can see that it's just a transform with this component,
which is a center machine virtual camera.
Keep this in mind. I'm going to open up and you can see
that we have a lot of things that we can add,
we can change, we can play around.
I'm not going to go into every single detail in here because there is a lot.
What I'm going to do is I'm going to first of all,
right-click and the hierarchy.
And I'm going to actually set this all 200 000.
And you can see that we have something that just disappeared.
And what seems to be the problem in here, virtual camera.
So the main camera.
Okay, so if I go into the 3D mode,
you'll notice that when the z is 0 means it's in front,
so we can't, we actually are looking from behind.
What I need to do is just move it slightly.
Back so we can see the view and you can see the camera in 3D right here.
These white lines represent what the camera sees.
I'm going to go back into 2D,
and then I'm going in the virtual camera.
You can see right here that we have an option for the follow and the
object that the camera wants to move with or the body and target.
So what is the object that I want to move with the doom player?
So I'm going to add the doom player,
and I'm going to save all of that.
Let's also make sure that we have these cameras nicely feathered.
So I'm going to create an empty game object,
reset its position is going to be the cameras.
And let's just make sure that these two cameras are a child of the cameras.
And now we have them set up properly.
Save that when I run the game, There you go.
You can see that now I have
a very nice follow cam that follows the player anywhere he goes.
But there are a lot of things that we can change using this camera.
So I'm going to first of all,
get out of clay mold,
make sure that we don't maximize on play.
And I'm going to go into the virtual camera.
And what are all of these things right here?
You can see that we can change this from transpose to other things.
As I've said, Go and look up what all of these things.
But one of the things that we mainly want to change is decomposed right here.
And you can see the look is required.
You can choose something different.
You can choose to do nothing with the aim.
These are all options that you can use.
And in here you can see that we can change this to framing transpose.
So change the body to framing transpose.
If you add the lookahead,
if I add the dome player and the look ahead, look what changes.
So now when I play the game,
you'll see something just a little bit different.
I think know until now seems to be the same.
You can keep the look ahead.
You can change, play around with the options.
I'm just going to show you the main things in here.
So in the body, first of all,
you can see the windows right here,
the different colors in the game.
It's because the game Windows guide right here in the Inspector,
I can turn them on and off.
So what do we have?
First of all, we have the look ahead,
we have the lookahead smoothing,
we have the x damping,
damping and so on and so forth.
I don't even know most of the things what they do exactly.
But a very good trick that you can do is you can actually go ahead and
increase this to its maximum and then play the game and see what happens.
So as you can see, yep, there we go.
So the camera is faster than the player.
And this is because the look ahead is very strong.
So if I smooth down the look ahead,
you'll notice that as we are walking the cameras starts moving
in front of the player and it's represented by this yellow small dot.
And here you can see that the dot predicts where the player is about to go and
sets the camera to go there just a little bit faster than the player.
If I set it to 0, it will simply move with the player as he's going.
We can increase the smoothing a little bit increased look ahead smoothing.
So now you can see it's a little bit smoother,
a little bit nicer.
And that, There you go.
What else do we have?
We can ignore the y,
so that will change the way it looks in the y direction.
And let's see what else do we have?
We have the x damping,
so let's put this to 20 and see what happens.
So there you go.
You can see that when the player hits the red side of this square or rectangle,
you can see that then the camera starts moving and if not,
it's slowly, slowly goes to the x, or you can set it to 0.
And in that case, whenever we are moving,
it's immediately following the layer.
Let's set it back to one.
Let's see what else we have.
We have the y damping, V, z damping.
Let's see, we have the screen x.
Let's see if we move it so we can play our game with the player being able to the right.
We can set it to be in the middle,
or we can set the widescreen to be at the bottom.
So there you go.
We have the camera distance,
which is a very nice touch,
and it's currently not working.
Maybe it's because the camera right here should have a bigger size.
I'm not sure what the problem here is.
And let's reset it.
So back in here, reset everything.
So let's keep it at 10.
We have the dead zone width.
So if I increase the dead zone width on the y and on the x, look what happens.
If I move up and down and left and right,
it stays in place.
And if I go outside the bounds,
then we start going while the camera starts going with the player.
So this is also something that you can tweak and play around.
And actually I'd like to make it just a little bit small.
So for example, if I walk around,
nothing happens and then when I start moving,
the camera starts following the player.
Okay, let's make it around zero-point two by 0.2.
And there we go.
So we can move a little bit around.
But when we go outside the bounds than the cameras starts following us.
Okay, Very nice.
What else do we have?
We have the zone depth that's tried to put it to 100, see what happens.
Not sure what exactly does.
But let's keep it at 0.
See what happens now?
Yep.
Oh, okay.
Seems to change a lot.
I think Let's put it to 20.
Nothing, nothing happens.
Let's keep it at 20.
The soft zone width,
I think the South Zone is the red square.
So if I set it to,
let's say, being small, what happens then?
I can't even get outside because of the heart or the dead zone width.
Okay, no worries about that.
Reset the position.
Let's see we have the bias.
So what happens? Okay, So now the red zone is biased towards the blue zone,
and you can go ahead and search all of these yourself.
And the only thing here is that virtual camera as a whole world by itself.
So if I want to go into every single detail,
I think I need a whole section by itself.
But using Cinema machine as an incredibly powerful
and one of the most modern tools that we have in our possession.
So I do recommend what you do is play around with all these settings.
See what works, see what doesn't.
But remember as you saw right now,
all the changes that we made went back or got reset.
Why?
Because all the changes that we make inside of
the game mode are then reset when we stop playing the game.
With that information, I recommend that you go
through Unity's documentation of the Senate machine,
see what happens, see what you can use.
So for example, we have something called the noise,
which we will be using in a couple of videos to make
our shooting mechanics just a little bit more impactful.
And was that done before I go,
let me issue you a small challenge and
your challenge is going to be to set up your machine.
So play around with all the settings you have on the same machine.
The best way to know what each thing does is by
taking it to the max and see what happens then.
Well, that information, I hope you enjoy it.
And in the next video,
we are going to be creating the doors or whatever you wanna call them,
you can call them doors,
or you can call them the places where we move from
one level to the next to the exit levels, whatever you wanna call them.
So well that done.
I hope you enjoy it and I'll see you in the next video.