Unity Daydream Preview - Raycast/camera alignment
I've just rebuilt my Google Cardboard game using the new Unity Daydream Preview, Previously I was using a recent version of the Google VR SDK.
I am using a raycast forward from the camera to determine the users gaze and allow interaction with objects via staring at them (actually just a slightly modified VREyeRaycaster from the VR standard assets: https://www.assetstore.unity3d.com/en/#!/content/32351)..
During testing I noticed that sometimes I needed to gaze above or below the object before it would register the raycast collision. It was as if the ray or hitboxes had been moved relative to the camera.
It seems to be consistent throughout the scene once it had been loaded (e.g. I always have to look slightly above all the objects, by about the same amount, to trigger the action).
I also think it is linked to the orientation of the phone when you load the scene, (or possibly the whole game), if I load things with the phone in landscape as if in the headset, the raycast seems to be aligned, if I load things with the phone flat on the desk or at a 45 degree angle that is when it is way off.
Any ideas what might be going on?
P.S. I've uploaded the version to google play as a public beta if you want to take a look:
https://play.google.com/apps/testing/uk.co.softkitty.puzzleroom
As a sanity check: is it possible this is due to the phone being misaligned in the headset? You can draw an X'ed-box around the raycast hit point, ensuring it follows your gaze properly, to confirm that a misalignment is not the issue.
Answer by Ice52 · Oct 21, 2016 at 08:57 AM
Think I may have found the answer.
I was using my own "neck" script to update the camera transform, (in the version of the Google VR SDK I was using previously, this was missing). After disabling this the problem disappeared.
The camera view still seemed to be accounting for neck though, so I suspect this has been put back into the SDK. Still don't quite understand why its affected by the orientation of the phone when initialising the level, but I think the lesson is don't update the camera transform in your own scripts.