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

CinemachineTrack not working in build

Discussion in 'Timeline' started by Yachta, Jun 7, 2022.

  1. Yachta

    Yachta

    Joined:
    May 14, 2018
    Posts:
    2
    Hello,

    I want to use CinemachineTrack in my timeline to control the camera, but it works in the editor, but not when built for PC.

    Since my game specifications do not allow a PrayableDirector to be placed in the scene, the following script is executed in Awake to bind the main camera to the timeline.

    Code (CSharp):
    1.  
    2. void BindCinemachineTrack()
    3. {
    4. if (!playableDirector.playableAsset.outputs.Any(x => x.streamName == "Cinemachine Track")) return;
    5. var binding = playableDirector.playableAsset.outputs.First(x => x.streamName == "Cinemachine Track");
    6. playableDirector.SetGenericBinding(binding.sourceObject,Camera.main.gameObject.GetComponent<CinemachineBrain>());
    7. }
    If I don't use the above code,and place PrayableDirector on the scene and set the camera to timeline window, it works fine.

    The version of Unity used is 2020.3.35f1, the version of Timeline is 1.4.8, and the version of Cinemachine is 2.6.15.

    Is there any way to solve this problem?
     
  2. Yachta

    Yachta

    Joined:
    May 14, 2018
    Posts:
    2
    Resolved.
    It was my mistake.
    It was caused by the fact that there were two cameras tagged as the main camera on the scene.
    I got the current Camera.main in debug.log and noticed that Camera.main was different before and after the build.