Search Unity

Bug? Cinemachine virtual camera activation inconsistency

Discussion in 'Cinemachine' started by Arkade, Jul 19, 2019.

  1. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Hi
    I'm getting inconsistent results depending on the order I do fundamentally the same thing with some Cinemachine virtual cameras. What am I doing wrong or is this a bug?

    I have 3 dolly cameras and a Clear Shot Camera with 1 free look camera under it. I wish to enable the dolly cameras when the player is in their respective trigger zones.

    I've uploaded a video of my confusing results so let's number the dolly cameras for reference as the order I visit first in the video.

    (1) and (2) are using Timeline-based blends per https://docs.unity3d.com/Packages/com.unity.cinemachine@2.3/manual/CinemachineTimeline.html due both to peer recommendation and recognition that this will allow more complex blends in future.

    They have 2 "hold" timelines -- one for enable and one for disable with 2 tracks. 1 activation present only in the enable. Both then have a Cinemachine Brain track that blends from FreeLook to the desired camera.

    (3) (near where there's a red wedge at the top) has custom code that simply activates the dolly camera's GameObject via a UnityEvent. I figure when I don't need the more complex blends, this will be simpler. Admittedly all of them are pretty simple atm.

    So here's the odd result and the video
    • 3,2,1 = all work
    • 3,1,2 = 3 and 1 work (2 fails)
    • 1,2,3 = 1 only works (2,3 fail)
    • 2,1,3 = 2 and 1 work (3 fails)
    • 2,3,1 = all work!?
    Here's the video of my confusing results:



    The debug on the right highlights potentially viable cameras. I've uploaded it here but it simply colours those that have active GameObject and enabled camera as yellow and, at the top, lists the CinemachineCore.mActiveCameras suggesting what I would have expected to be the camera that is used is in fact at the top of the list. ...but not present in the blend when it doesn't work for some reason?! I started looking at all the CinemachienBrain BrainFrame stuff and decided I should probably just ask :D

    Thanks in advance.
     
  2. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Here's a screenshot of both timelines in case relevant. It's reused by both (1) and (2).
     

    Attached Files:

  3. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    p.s. Per the FAQ's comment about hypersensitivity I prefer to not have spare virtual cameras enabled when not in any way needed. The game I'm doing this work for is already often CPU bound.
     
  4. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Update:
    • When I have all virtual cameras' gameobjects active at the start and deactivate them after 1 frame, nothing changes (beyond one of them is used for 1 frame and you can see it auto-blend to the freelook when the game is started).
    • When I use individual Timelines for (1) and (2), nothing changes. Suggests it's probably not some missing reference thing.
    • When I swap-out Timeline and use a
      UnityEvent
      to do
      gameObject.SetActive()
      , everything works correctly. Suggests something odd is being caused by Timeline.
    Happy to try any suggestions for things I might try to debug this better? Otherwise I guess I have to drop Timeline for now :(
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Hi @Arkade sorry for the delay. I have to confess that I'm having a little trouble understanding all this... let me just say a couple of things for now.

    1. When you use Timeline with a CM track with CM shot clips, you don't need activation tracks. The CM shot will auto-activate the referenced vcam while the clip is playing. So you can use deactivated vcams, and they will stay deactivated while the clip is not playing, and auto-activate when the clip is playing.

    2. It seems that you're using timeline simply to blend between vcams. This is overkill, as there are much simpler ways to go about this.

    I would suggest getting rid of the timelines and using trigger zones with the CinemachineTriggerAction behaviour. This will allow you to activate vcams when the player enters the trigger zone, and deactivate them again when the player exits, all without any custom code.

    If you want to control the blend times for the individual transitions, create entries for them in the Brain's custom blends asset. That's what it's for.