Using Dolly Track in Unity
A dolly track allows you to set up a path and have a virtual camera follow it to get shots where the camera moves around the scene. In this tutorial, I will show how to create a dolly track that allows the camera to move around the knight in the picture.
First, make sure to install cinemachine for the project you are working on.
Now create a virtual camera by right-clicking the hierarchy and selecting Cinemachine => Virtual Camera
Because you will add the virtual camera to the dolly track it is not as important to get the camera in the correct spot.
What you can do is create an empty game object and call it to look at. Position this game object on the knight and parent it to the knight so the object will follow the knight when it moves.
You will now add the look at empty game object to the virtual camera where it says look at. This will have the virtual camera focus on the game object.
To create the dolly track right-click the hierarchy and select Cinemachine => Dolly camera with track.
By default, the dolly track has CinemachineSmoothPath attached to it.
Delete this component and add the cinemachinepath component instead. This will give you more control of the dolly track.
Now when you click on a waypoint in the dolly track you will get three boxes that will allow you to adjust your dolly track.
From left to right the first box allows you to move the whole dolly track, The second allows you to change the location of the specific waypoint you selected, and the last allows you to change the trajectory (or tangent) of the path. The last one is how you make the camera curve.
To add your camera to the dolly track select the virtual camera and change the body from transposer to dolly track.
This is where you will drag your dolly track into the path slot.
Now to get the virtual camera to pan around the knight you will use the timeline window.
You can dock this window next to the console and dock the game view next to the scene view.
Now create an empty game object and for this example, I named it animation. Drag the virtual camera, dolly track, and knight into the animation game object. This will help with organization in the hierarchy.
With the animation game object selected create a new timeline using the timeline window
Now clear the animation slot and add your virtual camera to it. It will ask you to create an animation component if one does not exist. Select yes for this.
To record the animation select the red dot.
At the beginning of the animation drag the white bar to the 0 position and set the path position of your virtual camera to 0 in the body section. This will set the virtual camera to the first waypoint at the beginning of the animation.
Now drag the white bar to the length you want the animation to run and set the path position to 1.
You can now hit the red dot again to stop recording. You will be able to hit the play button in the timeline window to preview your animation.
To learn more about dolly tracks in Unity check out the official documentation using the link below: https://docs.unity3d.com/Packagesemail@example.com/manual/CinemachineDolly.html