Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Get a reference to the Camera on CinemachineTrack in Timeline

Discussion in 'Cinemachine' started by CDF, Feb 5, 2019.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    Hi, Is it possible to get a reference to the Camera object assigned to a "CinemachineTrack" at runtime?

    cameraReference.PNG

    I would like to get that reference through code if possible?

    The PlayableBinding.sourceObject from TimelineAsset.outputs is always CinemachineTrack.
    Doesn't look like there's a way to access the Brain that belongs on the track.

    Maybe I need to grab it from PlayableDirector.GetReferenceValue? But not sure what id to use there.

    Also, if I have a reference to that CinemachineBrain and call:
    director.GetGenericBinding(myCinemachineBrainReference)
    The result is null!

    I think I'm misunderstanding what bindings are. I assumed that the bound object was the object assigned to the track in the Timeline window?
     
  2. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    177
    You can get the object bound to a track through the PlayableDirector component; call
    PlayableDirector.GetGenericBinding 
    and use your Cinemachine track as the argument.

    You are correct; a binding is the object that is bound to a timeline track.
     
  3. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    Ah nice, making more sense now.
    You're a lifesaver