In this lesson, you will learn how to move beyond simple linear camera movement by designing complex, spline-based paths using Cinemachine Dolly Tracks for precise cinematic framing.
The Power of Splines
While basic Dolly Tracks are useful, designing custom trajectories allows your camera to swoop through environments with organic curves rather than rigid, jagged lines. In Cinemachine, this is achieved using the CinemachinePath component. A path is essentially a series of Waypoints that act as control points for a Bezier spline. By adjusting the "Tangent" values on these waypoints, you can smooth out the corners of your camera’s movement, creating professional, cinematic arcs.
Creating Your Trajectory
To set up a custom path:
- Create an empty GameObject and add the
CinemachinePathcomponent. - Under the Waypoints list, set the number of points you need.
- Use the Scene View to manipulate the handles of these points. You will notice the path automatically curves based on the tangent settings, allowing you to wrap your camera around objects or follow a character's specific movement corridor.
Once your path is drawn, your CinemachineVirtualCamera needs to be told to use it. Set the Body property of your Virtual Camera to Tracked Dolly. Assign your custom path to the Path slot, and set the Auto Dolly property if you want the camera to move automatically based on the closest point on the path relative to a target.
Precision Control via Scripting
If you need to control the camera's position along this spline manually (perhaps to sync with an Animator state), you can manipulate the m_PathPosition property of the CinemachineTrackedDolly component via C#:
using Cinemachine;
public class CameraPathController : MonoBehaviour
{
public CinemachineTrackedDolly dolly;
void Update()
{
// Smoothly move the camera along the path based on an animation value
dolly.m_PathPosition = Mathf.PingPong(Time.time * 0.5f, 10f);
}
}
By crafting these splines manually, you ensure the camera avoids geometry while maintaining the exact framing your scene requires.
Key Takeaway: Use the CinemachinePath component to define complex, curved trajectories, then use the TrackedDolly body in your Virtual Camera to transform those splines into smooth, professional cinematic sequences.