Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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:
    1,845
    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.