cancel
Showing results for 
Search instead for 
Did you mean: 

[Solved] How do you start a game in Unity facing the camera direction?

therealjbot
Honored Guest
Hi, I am building a VR game using Unity 5.5 with Oculus Utilities V1.10.0.  My game requires the user to face at a console to pilot a ship.  But depending where the Oculus sensor is located the game starts you facing in unpredictable angles. My game camera is facing straight down the z axis but when I start the game the Oculus is never facing that way. It can be way off center? Even when I point my headset right at the center of the sensor (before starting the game) it still doesn't point where my game Camera wants the starting position to be. But when I play games like EVE Valkyrie I always seem to be pointed in the right direction. 

Calling UnityEngine.VR.InputTracking.Recenter(); will only put the Oculus back to what ever the starting position was. This is never straight down the z axis (where my game camera was facing) but some other angle (depending on where the sensor is facing). 

Another weird thing to note is that the camera preview in the Unity Scene editor can show a different rendered position then what is being displayed on the Oculus? But I know its the camera that is being rendered to the Oculus because if I uncheck it, the image in the headset freezes.  

The camera in the Example scenes does the same thing.  When you start the example, you are facing a different angle then the game camera, depending on where the sensor is positioned. 

Its vital to my game that the player faces the console or else its not really playable. Its fine for them to look away but when they look straight forward the console needs to be right in the center of their view..
2 REPLIES 2

therealjbot
Honored Guest
Ok I figured it out!! Turning off the OVRCameraRig Script has put the Oculus headset back into alignment with my game cameras again!! The one part I forgot to mention in my last post was that I was using 2 camera layers for some of my effects.  Not only was the cameras off when I had OVRCameraRig turned on but  both cameras had different starting points making a real mess?   Now that I have it working both cameras align as they should and  UnityEngine.VR.InputTracking.Recenter(); does exactly was it should do!!

vrdaveb
Oculus Staff
depending where the Oculus sensor is located the game starts you facing in unpredictable angles.

If you want to take the user's initial head pose as the reference frame instead of starting out in a sensor-based reference frame, enable "Reset tracker on load" in the OVRManager inspector. It just calls InputTracking.Recenter, so if you're doing that yourself, it should also work.