Skip to main content
New Participant
February 25, 2014

NullReferenceException - Camera Offset problem

Hi guys, I'm attempting to port a project over to the Oculus and I've been having a lot of success so far but I've now hit a problem that is confusing me.

I've got a game that starts at the menu screen with a camera facing one way and then it moves backwards to the player starting location where it hands over to the actual player camera. However on the player camera I'm getting one error that's constantly stacking up on update:

NullReferenceException
OVRCameraController.ConfigureCamera (UnityEngine.Camera& camera, Single distOffset, Single perspOffset, single eyePositionOffset) (at Assets/OVR/Scripts/OVRCameraController.cs:263)
OVRCameraController.UpdateCameras() (at Assets/OVR/Scripts/OVRCameraController.cs:246)
OVRCameraController.Start() (at Assets/OVR/Scripts/OVRCameraController.cs:178)


I can see the effects it's casuing as it's not halting the game in anyway but the camera offset isn't working correctly so you feel a bit cross-eyed when using it.

The thing that's really confusing me is that the menu camera's are working perfectly fine, I've attempted bringing in the OVRCameraController again but it hasn't done anything differently.

Any suggestions would be much appreciated!

Edit://

I've put in some debug comments to see what's going on, it finds the cameras perfectly fine for my menu character but then it doesn't seem to find either on my player character. Still a bit confused but that may help someone help me :P
    This topic has been closed for replies.

    3 replies

    BlueHatAuthor
    New Participant
    February 25, 2014
    Sorry for the double post.

    Fixed the problem, I hadn't realised the order of execution. The OVRCameraController tries to find CameraLeft and CameraRight on Awake(). I was enabling the OVRCameraController before the two cameras which meant it was looking for them before they had been enabled creating this problem.

    Switched the enabling order around (and disabling for later) and my order of execution is sorted and everything is working as intended.

    Maybe this will help someone in the future. Loving the Unity OVR plugin!
    Inspiring
    February 26, 2014
    Thanks for posting the fix.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    May 24, 2014
    Thanks BlueHat for posting this! Had this problem and in case someone else comes across it, you can also manually set the Right Eye variable to true in the editor if your Camera controller is already in your hierarchy.
    Riftmax Theater 4D Multiplayer VR Cinema! http://www.riftmax.com - Latest DK2-ready version 0.415(11/27/2014)