Unable to change FOV of the google card board camera
Asked Answered
S

2

5

I am developing a sniper game for android using Google card board unity SDK. Now there is the need to tweak the camera's FOV which leads me to interact a variable named 'mockFieldOfView' in CardBoard.cs. Tweaking that value in the Unity editor is fine but as soon as I make a build for Android it doesn't take effect at all. I'm unable to figure out the issue. Any idea or suggestion would be highly appreciated.

Apologize for the late reply, so ouflak you can see complete Cardboard.cs here Cardboard.cs

Sym answered 19/1, 2015 at 12:43 Comment(1)
We'd need to see some code to even make the first bit of a guess ourselves.Deceitful
S
5

You don't want to change "mockFieldOfView". That only affects the in-editor FOV. The value you want to change is "matchMonoFOV" on the StereoController. You also have to set a "CenterOfInterest" game object on the StereoController. It makes the stereo FOV attempt to match the FOV on the Main Camera (or whichever camera has the StereoController script).

See StereoController.cs

Update: v0.4.5 of Cardboard SDK supports your use case. Use "matchByZoom" and set the FOV you want on the StereoController's camera. No center of interest is needed.

Serriform answered 20/1, 2015 at 8:37 Comment(4)
Hi smd, I tried changing "matchMonoFOV" and seems it's quite similar to changing FOV, that's good, But I found really weird behavior when I rotate my head. What is happening now is changing in "matchMonoFOV" translates the camera which is child of Player. When player rotates it's head the camera turns to spectator and goes off and through the terrain because of its translation. How would I fix it(How to avoid translation of the camera instead we need rotation)?Sym
What is the FOV of the mono camera? Where do you have the CenterOfInterest game object?Serriform
Ah, since you mentioned that it is a sniper game, I'm guessing the trouble is when looking through the scope? I think the matchMonoFOV method is not the way to go for that case. Viewing through a scope is not a VR situation.Serriform
Can you try an experiment? Edit CardboardEye.cs and comment out these two lines: "camera.projectionMatrix = proj;" and "camera.fieldOfView = [complicated math];" This will leave each stereo eye FOV the same as the parent camera. When you set the parent camera to a "viewing through the scope" FOV, does it work any better?Serriform
W
1

I had the same issue and in my case it helped to put the MainCamera closer to the object which was the Cockpit of a car in my case.

In order to put the MainCamera closer than 1 real-world-meter to the object you must change the default-minimum-value in Cardboard.cs - I use the following setting:

private readonly Vector2 defaultComfortableViewingRange = new Vector2(0.0f, 100000.0f);
Whelm answered 16/6, 2015 at 17:55 Comment(1)
You can disable the comfort range checking by clearing the StereoController's "Check Stereo Comfort" box. That will bypass checking the viewing range vector altogether.Serriform

© 2022 - 2024 — McMap. All rights reserved.