Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Null ref exception in the Brain

Discussion in 'Cinemachine' started by Redux, Dec 7, 2018.

  1. Redux


    Nov 10, 2011
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Cinemachine.CinemachineBrain.ProcessActiveCamera (Single deltaTime) (at C:/Users/Shatt/AppData/Local/Unity/cache/packages/
    3. Cinemachine.CinemachineBrain.LateUpdate () (at C:/Users/Shatt/AppData/Local/Unity/cache/packages/
    Cinemachine 2.2.7 here.

    The only thing I'm really doing is setting priorities via script and calling MoveToTopOfPrioritySubqueue() on the camera I've affected.

    Any help appreciated, I'd like to clear this up.

    I also disable camera's via script (enabled = false) on the virtual camera. Not sure if that would be relevant.
  2. Gregoryl


    Unity Technologies

    Dec 22, 2016
    What's happening is that there is no current active vcam, and the Brain is complaining. In fact it's a bug, and the latest CM 2.2.8 (available in preview) gracefully handles the case when there is no current active vcam.

    You can work around this by ensuing that there is always an active vcam. Maybe have a dummy "do nothing" one on the brain itself, just to catch those frames when nothing else is active.