S: CinemachineDollyTrackMover, Move a Cinemachine Dolly Track Camera on the Track

CinemachineDollyTrackMover Script lets you move a Cinemachine Virtual Camera to Move on a Dolly Track Path.

Fancy Script that makes the CinemachineVirtualCamera move on the CinemachineTrackedDolly


					using Cinemachine;
using UnityEngine;

public class CinemachineDollyTrackMover : MonoBehaviour
    [SerializeField] float cameraSpeed = 10;

    CinemachineVirtualCamera m_Camera;
    CinemachineTrackedDolly m_CameraDolly;

    void Start()
        m_Camera = GetComponent<CinemachineVirtualCamera>();
        m_CameraDolly = m_Camera.GetCinemachineComponent<CinemachineTrackedDolly>();

    void Update()
        m_CameraDolly.m_PathPosition += Time.deltaTime * cameraSpeed / 100;

You can attach this Script to a CinemachineVirtualCamera that has a CinemachineTrackedDolly Component. Adjust the desired speed and the Camera will run on the Path of the Cinemachine.

The Script pulls the necessary Component References at Start. You cannot assign the CinemachineTrackedDolly through the Inspector. You need to get the Cinemachine Component from the Cinemachine Camera.

Update it with additional Logic, what happens when it reaches the end of the Path and other stuff. Check out Unity Cinemachine for more Information

Happy Development <3

Leave a Reply

Your email address will not be published.