- [Narrator] In this video,
we're going to take a look
at the Free Look Camera component in Cinemachine.
We're going to look at how FreeLook can be used
to orbit a transform,
based on input from an axis.
We're also going to look at how we can customize
the FreeLook camera component
to get our intended composition on each stage of input.
In this demo we have a ship that the player can control
and are currently locked off the virtual camera
following the transform as it moves around the screen.
It's common in games like this
for the player to have control of the camera
so that they can get a look ahead around corners
or simply get a better more preferable angle
of their avatar.
Cinemachine's FreeLook camera component
allows us to set up an access controlled camera
that orbits a target.
To get started
let's create a new Cinemachine FreeLook camera.
We deactivate the old follow camera
and then in our new FreeLook Camera,
assign the look at and follow property to the ship.
Now if we play, we can see that as the mouse moves,
our camera orbits around the ship.
However it needs some fine-tuning.
Back in the inspector,
let's slow down the speed of the x-axis
to get a smoother movement on the camera rotation
as our mouse moves from left to right.
We turn off invert too
as I'd like the camera to aim
towards where I'm pointing my mouse.
The FreeLook Camera blends between
three different rig states.
A top rig, a middle rig and a bottom rig.
Cinemachine does this to give us much more control
over the position and composition of our camera
at different stages of orbit.
In the scene view we can see the FreeLook gizmo
showing us a wireframe representation of our settings.
If we change a rig height or radius,
we can see the gizmo update in the scene view.
To preview what the camera looks like
at different positions on the rig
we can simply change the value setting of the X or y-axis
in the inspector.
>From here we can adjust the camera composition
with the aim settings in the same way we would
with any other Cinemachine camera,
either by using the guides
or adjusting the values in the inspector.
If we change the value on the y-axis,
the guides will switch to the corresponding part of the rig.
If for instance,
we'd like to change the field of view on the camera
at a certain point in the rig,
such as when the camera is low to the ground,
we can disable the used common lens settings toggle
and customize the lens setting
for each of our aim properties on our rig.
Finally by changing the spline tension on our rig
we can adjust how the camera moves between each point.
A lower value causes the linear blend between the states
and a higher value will create a curved movement.
>From here, we can simply adjust and tweak
our aim and rig values
to get the best settings for our project.
It's also worth noting
that we can animate the values of the FreeLook Camera
for use in cutscenes or control it with custom scripts.
Should we wish to remove control input from the player,
we can simply remove the input axis name property.
We can then drive the value property manually
using an animator or by referencing our free lip component
in a custom script and setting the m underscore x-axis
or m underscore y axis value.
As you can see the FreeLook Camera component Cinemachine
makes it easy and simple
to create a user controlled camera in our project.
For more information on Cinemachine
and for more unity tutorials,
please follow the links below.
Thanks for watching.