How to Dolly/Track a Camera in Unity
While I've previously discussed Virtual Cameras with Track Dolly Body settings, I want to go over Cinemachine’s Dolly Camera with Track and Dolly Track with Cart. The aforementioned virtual cameras are a more simplified way to achieve the Track Dolly behavior
Essentially, both virtual cameras accomplish the same — they use an established path composed of waypoints to move or animate the camera along its course.
The main difference between the two:
- Dolly Track with Cart moves at a consistent speed instead of performing auto-dolly. The user sets the speed, and the camera will move across the dolly track regardless of whether its targeted object is moving or not.
- The Dolly Camera with Track does auto-dolly, so it will automatically follow a target whenever it moves. The user does not have control of the speed.
It’s a lot easier to grasp the concept with an example, so let’s get to it!
Objective: Learn how to use Dolly Camera with Track and Dolly Track with Cart to dolly and track a camera in Unity. And how to tell the difference between the two.
Table of Contents
· Dolly Camera with Track
∘ Dolly Camera with Track Result
· Dolly Track with Cart
∘ Dolly Track with Cart Result
You can catch up with all my Cinemachine articles here.
Dolly Camera with Track
- Let’s start by adding in the Dolly Camera with Track via the Cinemachine menu.
When you add it, you will notice that a Virtual Camera is automatically added with a Dolly Track object.
If you take a look at the camera in the Inspector, you can see that it comes preset with a Tracked Dolly Body.
This is what the Dolly Track should look like in your scene view.
2. Add a Look At and Follow target — this is the object you want to keep in view at all times. In my case, this will be my character. You can learn more about Look At, Follow and Body here.
3. You will also need to add the Dolly Track to the Path in the Body settings.
4. Enable the Auto-dolly check box.
Dolly Camera with Track Result
Now when you press play and move your character, the camera will automatically follow the object along the track. The auto-dolly will always follow the character.
Dolly Track with Cart
- Let’s add our Dolly Track with Cart via the Cinemachine menu.
This time, you will notice that the track is added along a cart. The cart lets us edit things like speed and position, so this will always move at a consistent designated speed. There is no auto-dolly.
You can also determine the measuring(Position) units for how the position changes, and then Update method, which is in relation to how the changes in position and speed occur over frames or time, the same as the default Update method from C# scripts in Unity.
2. Back at the Dolly Track, it works pretty much the same as the previous one. Here we can set our path waypoints as well as add more. So here, I’m just adding more as an example.
3. Let’s set the speed of our cart.
3. We’re going to need a virtual camera.
This virtual camera will have the Dolly Cart as its Follow target.
And the object or character will be the Look At target.
Dolly Track with Cart Result
When you press play, the cart will move at a consistent speed even if the character or object is not moving. It will not automatically move with the object, it moves regardless.
If you want this movement to loop back and forth around the track you can Check the Looped box in the track.
This is what it looks like with looping enabled.