Search Unity

Route

Discussion in 'Cinemachine' started by Truls_, Oct 1, 2018.

  1. Truls_

    Truls_

    Joined:
    Dec 4, 2016
    Posts:
    105
    Is it possible on a dolly-camera to set the route/railtrack in script? like set point A and B through script and then set the camera active and make it follow the track?
     
  2. hex21189

    hex21189

    Joined:
    May 28, 2013
    Posts:
    11
    You should be able to do it in script. I'm pretty new to Cinemachine but I think if you were to create your virtual cameras (you probably have a prefab for it) in a co-routine then you can add them as needed with increasing priority. That way your CineMachine brain will automatically blend between them. If you create a custom blend in code you can control the time between them or you can use the default blend if you don't really care about the specific timing.
     
  3. Truls_

    Truls_

    Joined:
    Dec 4, 2016
    Posts:
    105
    But I still don't know how to write it or what to use.. I can't find any documentation on how to write the code or how to use the different classes etc..
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    CinemachinePath owns an array of waypoints. You can assign this array from script. Look at the CinemachineSmoothPath script, it has inline documentation. Set the m_Waypoints field to be the array of waypoints. You can change them dynamically, and any vcam following the path respond.

    On thing: After changing the wayoint array, be sure to call path.InvalidateDistanceCache() to force recalculation of the cached info about the path.

    You can activate/deactivate a vcam from script simply by calling SetActive() on its gameObject.