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

Changing culling mask causes cinemachine brain's live camera to none

Discussion in 'Cinemachine' started by WHiPerino, Jan 17, 2019.

  1. WHiPerino

    WHiPerino

    Joined:
    Jul 1, 2016
    Posts:
    7
    Hi there,

    I am currently using Cinemachine State Driven Camera. I also have a Cinemachine Brain attached to MainCamera.

    My expectation :
    When it changes to from State A to State B, I would want the main camera to show certain layers only during State B.

    Outcome:
    Cinemachine Brain's Live Camera shows State Driven Camera's transform. No problem so far. However, when I change the MainCamera's culling mask layers using script during runtime, the Cinemachine Brain's Live Camera would become none.

    My current workaround would be adding a Camera component to that state vcam object with its culling mask layers set beforehand. So whenever it changes to that state, I would enable the camera component when its live and disable the camera when its not.

    Just wondering if this is a known issue.

    Thanks.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    The Brain only sees vcams that are on layers not filtered out by the camera's culling mask. This is to allow scenes to have multiple Brain/Camera pairs for things like splitscreen.

    If I understand your problem correctly, the fix would be to put all your vcams on a special vcam layer, and make sure that layer is always present in the culling mask, as the state changes from A to B.
     
  3. WHiPerino

    WHiPerino

    Joined:
    Jul 1, 2016
    Posts:
    7
    Aha it makes sense now. Thanks!
     
    xiguoliang8610 likes this.
  4. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    205
    I just spent 2 hours trying to figure out why the brain/vcam stopped working during a cutscene I had set up where the camera's culling mask gets changed. Thankfully I found this post after figuring out it was for some reason tied to the camera's culling mask. I would have never figure out why this is happening, or how to fix it if this post didn't exist. Linking these two things together (vcams and culling mask) makes absolutely no sense to me. I understand how the setup can be handy for the splitscreen/multi cameras setup, but that seems like a more niche thing to do then for people to simply be changing their camera's culling mask.

    So everyone that changes their camera's culling mask runs into this issue and has to figure out why this behavior is happening. :mad:
     
    GibTreaty likes this.