cancel
Showing results for 
Search instead for 
Did you mean: 

Unity: 1 unit = 1 metre. Very important!

grodenglaive
Honored Guest
It took me awhile to figure out why everything in my project looked sort of flat in the rift, while other people's demos really popped out at you. I had made a noob mistake and built my scene in Unity using centimetres instead of metres. Now, while everything looked to scale, the trouble was when Unity fetched my ipd it was 100 times too small. This effectively gave a zero IPD, so the left and right eye images were identical. Rather than rescaling my entire scene I just added a fudge factor to the camera controller script.
If anyone else does something similarly stupid, like using inches or feet, here's how to easily fix it.

Edit the OVRCameraController.cs script. In void UpdateCameras add a multiplier factor to the eye position offset (in my case 100😞

float distOffset = 0.5f + (LensOffsetLeft * 0.5f);
float perspOffset = LensOffsetLeft;
float eyePositionOffset = -IPD * 100 * 0.5f;
ConfigureCamera(ref CameraLeft, distOffset, perspOffset, eyePositionOffset);

distOffset = 0.5f + (LensOffsetRight * 0.5f);
perspOffset = LensOffsetRight;
eyePositionOffset = IPD * 100 * 0.5f;
ConfigureCamera(ref CameraRight, distOffset, perspOffset, eyePositionOffset);

And that's it - I hope someone finds it useful.
34 REPLIES 34

DaveA
Honored Guest
Great! Would be nice if OculusVR incorporated this into a future release. I've had to hack those files myself. I wonder if they read this stuff, or is there a preferred way to submit such requests/fixes/mods to their code?

owenwp
Expert Protege
Something Oculus might consider is adding a to-scale 3D model of the rift to the camera controller, that tracks properly while the game is running.

This way it should be obvious if things dont fit right when we look at our scenes in the editor. Adding a human biped model of the developer's configured height to the player controller might help too, at least in edit mode.

Scale is really easy to perceive when actually using the Rift, but when you are building your game on a regular monitor it is definitely not.

raidho36
Explorer
What about you just model everything in exactly 1:1 scale? That is simple enough concept. You don't even need to check it out in the rift - it's just by definition the right scale.

Phylliida
Explorer
This is super late but one way to do this is do the following:

- Game Object with desired scale
---- Game Object with scale = (1,1,1)
-------- VR Camera

If you just scale the game object holding the VR Camera, your view will be scaled but your position won't be and it'll feel weird. A second parent fixes that.

Viconthebeach
Protege

My room is 4 meters large and my 3D room is 4 meters large in Unity units, when building to the headset I get something like 4,10 meters between the 3D walls. I'm going to mesure it with anchors and see what factor is to be applied for real matching units.