Search Unity

How to use CinemachineTrack if the BrainCamera is in a different scene...?

Discussion in 'Cinemachine' started by oxysofts, Jun 13, 2019.

  1. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    Hi, I have a bit of a conundrum on my hands.

    First: I've read on this forum that it is good practice to have a single BrainCamera and handle the rest with VCams alone, which makes sense to me. Therefore, we have a global scene in our game with a single BrainCamera driven by various VCams throughout the game.

    Currently we are starting to discover the power of timelines and are betting more and more on them. Today, I attempted to use a CinemachineTrack to streamline my workflow. Previously I was actually animating the priority property manually which is a bit ridiculous considering what is offered with the CinemachineTrack and how clean it is in comparison.

    However I hit a wall: I must bind the CinemachineBrain to the track, but the reference is lost whenever I enter play mode.

    I assume because Unity cannot keep track of objects in a different scene? Personally I don't even understand how it would work in the first place with the other scene since timelines are assets and don't live in a scene. This hints that it may be a bug and the reference should not be lost.

    If this is the expected behavior, I had the idea to iterate the tracks before playing a TimelineAsset in order to find the CinemachineTrack and manually plug the brain into it at runtime. It's getting late though so I'll just leave this here and hopefully someone can shed some light! I'd like to know whether or not this is a bug and what should be my next move.

    Thanks!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    You could make one Camera/brain per scene instead of the single global one. That would work, but you would not by default get camera blends between the scenes - just cuts. Maybe that's good enough for your application.

    If you want a single global camera/brain, then you'll have to bind it to the CM Tracks in the timelines after the scenes are loaded. You can iterate through the tracks in the timeline, looking for CM tracks, and dynamically bind those to the brain. Ask on the timeline forum for details about how to do that.

    Or just look here: https://forum.unity.com/threads/bin...ect-to-a-timeline-in-a-tempoary-scene.550357/
     
  3. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    Indeed we wish to keep a single CinemachineBrain so we can seamlessly transition between different scenes, if need be. Sucks we have to do a bit of manual legwork for this but it's all good. Thanks for the answer!