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

    Redux

    Joined:
    Nov 10, 2011
    Posts:
    112
    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/packages.unity.com/com.unity.cinemachine@2.2.7/Runtime/Behaviours/CinemachineBrain.cs:487)
    3. Cinemachine.CinemachineBrain.LateUpdate () (at C:/Users/Shatt/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.cinemachine@2.2.7/Runtime/Behaviours/CinemachineBrain.cs:258)
    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.

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

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,357
    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.