Cinemachine and Group Targets in Unity

Chris Hilton
3 min readJan 17, 2022

Objective: To learn how to keep multiple targets in the frame.

Group Composer Aim Setting

Cinemachine is absolutely fantastic with being able to keep a single target in the frame, but is it able to do this with multiple targets? Let’s take a look at a ‘Group Composer’ feature in the ‘Aimsettings.

What is the Group Target ‘Aim’ Setting in Cinemachine?

This setting is Cinemachines way of saying let’s take a bunch of individual targets and treat them as if it was 1 ‘LookAt’ target.

Let’s Get This Virtual Camera Setup

To start let’s add the virtual camera to the scene, ‘Cinemachine’ tab → ‘Create Virtual Camera’. This will now be added as a game object in your scene.

Adding a new virtual camera to a scene

Next we are going to create the ‘TargetGroupgame object and add a CinemachineTargetGroup component to it. Create Empty Game Object in Hierarchy → Rename to ‘TargetGroup’ → Add component in the Inspector ‘CinemachineTargetGroup’:

Creating a TargetGroup and also adding the CinemachineTargetGroup component

Now let’s change the ‘Aimsetting in the CinemachineVirtualCamera component in the Inspector and also add the newly created ‘TargetGroup’ to the ‘LookAt’ field:

Updating the Aim settings to be ‘Group Composer’ and adding TargetGroup game object to the ‘LookAt’ field

You might be met this small error, which is perfectly fine. It is basically letting us know that there is no group targets added to the component yet. So let’s add some!

But first, we need to add a couple cubes to either side of the capsule so that we have multiple targets:

Now, let’s add these targets to the CinemachineGroupTarget component on the ‘TargetGroupgame object:

Adding targets to the CinemachineGroupTarget component

On your Game view tab, you may now see these yellow lines across the screen which is going to help us track multiple targets to be in the same frame:

Yellow Lines in Game view tab

Let’s Test It!

It is time to see if our magic has paid off. We are hoping to see that when we move the capsule back and forth, the virtual camera will automatically adjust itself to make sure that all the targets are in the same frame:

Success!! That was super easy to setup and we haven’t even begun to play around with all the additional settings available to us in the ‘Aimsettings and also the ‘CinemachineTargetGroup’ component:

Group Composer Aim settings
CinemachineTargetGroup component settings

--

--