Forum Discussion
BlueHat
11 years agoHonored Guest
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:
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
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
3 Replies
Replies have been turned off for this discussion
- BlueHatHonored GuestSorry 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! - cyberealityGrand ChampionThanks for posting the fix.
- MikeArms24Honored GuestThanks 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.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago
- 8 months ago