Tracked Dolly Virtual Camera Explained in Unity’s Cinemachine

Chris Hilton
6 min readJan 15, 2022

--

Objective: To understand what the Tracked Dolly virtual camera is in Unity’s Cinemachine and how to use it.

Tracked dolly virtual camera

What is the Tracked Dolly Virtual Camera?

The tracked dolly virtual camera is restricted to the movement on a predefined path.

The ‘Path Position’ field is where you would like to place your virtual camera along the given path, additionally creating an offset position from this if required.

There is one concern when using this virtual camera compared to the others and that is to be careful of the shapes of the paths you are creating. If you were to create a perfect circle or a semi-circle around the target, the camera wouldn’t be able to find it’s closest position to the target as everywhere on this path is the same distance to the target. This could cause the camera to move large distances, when the target is only moving short.

Tracked Dolly Settings

Tracked Dolly settings

As you can see when you change your ‘Bodysetting to tracked dolly you will be met with this error. This is because the tracked dolly virtual camera requires a predefined path. You can fix this by adding one of the following components to an empty game object and then adding it to the ‘Pathfield, CinemachinePath or CinemachineSmoothPath:

CinemachinePath and CinemachineSmoothPath components

What are the CinemachinePath and CinemachineSmoothPath Components?

Both of these use an array of waypoints for the tracked dolly to move to in a world space setting. Both use something called the ‘Bezier interpolation’ method between the waypoints to help provide a smooth and continuous path for the tracked dolly virtual camera.

There are a couple of differences between the two (mainly regarding first and second waypoints being guaranteed and potential jittering with the CinemachinePath), but these explanations are unfortunately out of my league to try and explain, so I will provide the links below for you to research!

How to Get the Path Setup

I will use the CinemachineSmoothPath for this, so make sure this is attached to an empty game object and then assigned to the ‘Path’ field.

CinemachineSmoothPath

When you have done this you should see a green line on your screen that depicts the path (I changed the colour to blue — ‘Path Color’ setting):

Tracked Dolly path

As you can see this will be the predefined path that the tracked dolly is allowed to move along and this is automatically setup between 2 waypoints to start with. Let’s add a couple more points. Have your smooth path game object highlighted and press the ‘+button under the waypoints tab, which will add a new waypoint which we can move around:

Adding a new waypoint and moving it’s position

Now when we hit ‘Play’, you should see egg man move forward and the tracked dolly should be trying to stay as close to the target along the predefined path:

Tracked dolly moving automatically to keep as close to the target as it can along the predefined path

Width

This is the track width and can be increased in size:

Increasing the width of the track

Looped

Ticking this box will make both the ends of the path join together to create a loop:

Looped track

Tracked Dolly Settings Continued

Path Position

The position in which the tracked dolly is located and is dependant on which position units mode is used(below). Can be setup manually or auto dolly feature can be enabled.

Position Units

Path units — This is determined by how many waypoints there are.
E.g. If I have 3 waypoints, I have the option to set the path position (above) to either 0, 1 or 2 which is waypoint 1, 2 and 3 respectively. If I was to input 10, then it would revert to the last waypoint possible (3).

Path Distance — Represents the total distance of the path. This value can be found on the smooth path game object:

Total path length in the CinemachineSmoothPath component, located on the smooth path game object

Below is a distance of 15, out of the possible 25.51:

Path position of 15, using the distance method

Normalised

This makes the total path length a value between 0 (start point) and 1 (end point).
E.g. If I was to set this value to 0.5 it will sit right in the middle of the track (approx. 12.25 if we were using path distance):

Normalised path set to 0.5 path distance

Path Offset

The offset position of the virtual camera relative the predefined track path.
E.g. If i was to increase the Y axis then the virtual camera would be raised above the track, but it would still follow the track.

Damping

Has been previously discussed here.

Camera Up

This setting determines how to set the ‘Upvector for the virtual camera.

Default — This mode uses the World Up Override property in the Cinemachine Brain (located on the Main Camera game object):

World Up Override in the Cinemachine Brain Component on the Main Camera

Path — This mode uses the current paths up vector. It allows you to also adjust the pitch, yaw and roll damping values.

Path mode

Path, No Roll — Same as above, but there is no Roll damping:

Path mode, no roll

Follow Target — Compared to the ‘path’ mode, this uses the ‘Followtarget’s transform as the up vector.

Follow target mode

Follow Target, No Roll — Same as above, but with no Roll damping.

Follow Target, no roll

These different camera modes can be a little difficult to show the differences, so best to play around with them in your scene to get the best camera views!

Auto Dolly

This enables the auto dolly feature to track the target and automatically move this virtual camera to the closest point along the predefined path. The ‘Followtarget must not be empty.

Position Offset

This offsets the auto dolly, based on the currentposition unit’, using the closest point on the path to the target.
E.g. If I was to use Distance as the ‘position unit’, I could move the offset from 0 to 25.51 and this would move the auto dolly camera along the path to the specified distance:

Auto Dolly position offset along the track
Increasing the offset to 25 and back to 0, moving to auto dolly virtual camera long the predefined path

Search Radius

This features searches for additional waypoints that are on either side of the current position. If you want this to search the entire path, set this value to 0.
E.g. If I was set this to 5, it would search for the 5 waypoints towards both the start of the track and the end of the track if I was sitting in the middle of the path and I had this many waypoints either way.

Search Resolution

This feature searches between a segment using straight lines. The higher the resolution number, the more straight lines and the higher the accuracy, albeit this decreases performance.

How Would We Make Changes at Runtime Through Scripting?

Take a look at this previous article which covers this.

--

--