Aiming Features in Cinemachine
Objective: To look into the aiming features of the virtual camera in Cinemachine in Unity.
When you first create your new virtual camera, there will automatically be a new CinemachineVirtualCamera component attached to the game object. Within this component, and beneath the Lens Settings, we get a first look at our ‘Aim’ features for the camera and the many fields we can play around with to get the camera setup exactly how we want. Let’s take a quick look into these settings!
Aim Feature in CinemachineVirtualCamera Component
Within ‘Aim’ we are presented with a drop down box with 3 options — Hard Constraint, Composer and Group Composer, let’s discuss these:
Hard Constraint
Hard Constraint essentially removes all the other settings that we can adjust and simply keeps the ‘LookAt’ target in the dead centre of the camera.
Let’s take a quick look at the Hard Constraint Aim feature in action:
As you can see the camera is stuck to the LookAt target in the centre of the screen the whole time, and all of adjustment boxes have been removed. As you will now see below with the Composer option, the camera will have offsets and dead/soft zones.
Composer
The Composer is similar to the Hard Constraint in the way that the LookAt target is in the middle of the camera however, it doesn’t necessarily need to be dead centre and often uses offsets, damping, dead zones and soft zones to move the camera around.
Let’s take a quick look at the Composer feature in action:
Damping refers to how aggressively the camera is going to follow the target, the lower the number the more responsive the camera will be and the higher numbers will mean it reacts more slowly. This can be adjusted on both the horizontal and vertical axis.
The Dead Zone is the middle grey box in the centre of the screen. If the target is within this zone, the camera will not move.
The Soft Zone is the red area on the screen and it means that when the target is within this zone, the camera will rotate towards the desired position depending on the damping settings as discussed above.
Group Constraint
Group Constraint aims the camera at multiple game objects in the frame. and we are presented with more additional settings to play around with, along with an error that let’s us know that the “LookAt target must be a Cinemachine TargetGroup”.
To fix this error, let’s add a Target Group to the LookAt box. We can complete this by going to Cinemachine tab → Create Group Target Camera. This will create a new virtual camera, along with a target group that already has been assigned to both the ‘LookAt’ and ‘Follow’ fields. We can also use this TargetGroup to be assigned to our original virtual camera, and we can delete the new virtual camera created.
The TargetGroup will now have a script component attached to it called ‘CinemachineTargetGroup’ and this is where you can add game objects as ‘targets’ and adjust the weighting and radius of each.