Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

CinemachineTrack not working in build

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

  1. Yachta


    May 14, 2018

    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):
    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


    May 14, 2018
    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.