Think of an exciting scene from an action movie you love. Maybe with cars? Ever wondered how do they keep the camera at the same level while moving forward with the characters? Yeah, probably all of us saw this thing, but I did not know what it is actually called.
So we got the point. But how do we use it in our game? Cinemachine has the answer. Simply click on Cinemachine — Create Dolly Camera with Track.
Once you click, you will realize that a “Dolly Track” and a virtual camera game objects will be added to the scene. If you already have a cinemachine camera in the scene to be used for the cutscene, you can just delete the new Cinemachine virtual camera game object.
By clicking “Add a waypoint to the path”, we can easily start to create the path for our dolly track.
Then, you will realized that the first waypoint (0) will be added to the waypoints. By clicking + button, we can add waypoints according to our need.
Again, Unity allows us to manipulate the transform of each of these waypoints easily. And now we start to see the path of the dolly track on the screen view.
The anchors are numbered according to waypoint number. As can be seen above, the dolly track starts from the Waypoint 0 on the right hand side, and moves towards to left (the number under the second anchor is 1, which is not visible on the shot). The 3rd anchor is used for giving an angled turn to the dolly track.
By moving the 3rd anchor, we can make a way for the dolly track around the guardian. In order to get our virtual camera on the track; select the virtual camera game object and change it’s body from Transposer to Tracked Dolly.
And drag & drop the newly created dolly track to the Path field that opened once we select “Tracked Dolly”.
Path position represents the waypoint numbers. 0 denotes that the virtual camera is at the position of the starting waypoint 0 of the dolly track.
Animating The Dolly Track
To animate the virtual camera on the dolly track, we need to use Timeline. Switch to the game object that we have started to use the Timeline for the corresponding cutscene, and add an animation track. Then, drag and drop the virtual camera which we positioned on the dolly track. As we know, Unity will automatically ask and add the Animator component if it doesn’t exist on the virtual camera before.
Then, just use the record button for animating :) In order to make sure that the camera starts at the waypoint 0 of the dolly track and end on the Waypoint 1; do not forget to change the Path position of the virtual camera to 0 at the start of the animation, and 1 at the end.
And that’s it!