Skip to main content
Up and Coming
January 2, 2014

Unity: 1 unit = 1 metre. Very important!

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.
    This topic has been closed for replies.

    34 replies

    Up and Coming
    February 18, 2014
    Ok, we're using 2 different modelling programs. What I was referring to was 3dsMax - I'm not sure if sketchup has the same "unit setup".

    From a quick search on google, I did find this:

    Known Issues
    Unity Scale Calibration

    SketchUp's basic unit is the inch. Thus: 1 inch in SketchUp = 1 unit (meter) in Unity. If you use meters in SketchUp, your model will be ~39.37 times too large.
    Current WIPs using Unreal Engine 4: Agrona - Tales of an Era : Medieval Fantasy MORPG
    Up and Coming
    February 18, 2014
    Thats pretty straightforward, in Unity just go to the fbx model and change the import scale. You'll either fiddle with the other program to export the same scale or use a different import scale for files produced from each program.
    Brevis / DevBlog Twitter
    Up and Coming
    February 18, 2014
    I my case, I am using meters.
    When I export from Sketchup, I make sure the export units are meters also.
    When importing my cube in Unity, it is one unit. If I draw a cube inside Unity of 1 unit size, it is identical to the one imported from Sketchup... So this means my dimensions are correct... but does not explain why a very small eyes height in OVR settings does not make you just above the floor...
    Could you try it out on your side ? Like setting camera root position to 0, neck position to 0.1 and eyes height to 0.05 (total is 0.15 meter = 15cm = ~6 inches). In that case, do you have your camera at corresponding distance above the floor ?
    Up and Coming
    February 18, 2014
    From my quick tests (keep in mind that I don't have a headset yet), I had to manually lower the OVRCameraController down along the Y axis. There were some other interesting things going on since the game doesn't detect the headset (such as the left and right eyes being wildley off-set along the Y axis) but that is what it is.
    Current WIPs using Unreal Engine 4: Agrona - Tales of an Era : Medieval Fantasy MORPG
    Up and Coming
    February 18, 2014
    saviornt, thanks for this.

    Anyone with a dev kit can test and confirm this ?
    Should playing only with camera root/neck/eyes position variables not be enough ?
    Up and Coming
    February 18, 2014
    "bdeschryver" wrote:
    saviornt, thanks for this.

    Anyone with a dev kit can test and confirm this ?
    Should playing only with camera root/neck/eyes position variables not be enough ?


    It seems fine to me.
    Brevis / DevBlog Twitter
    Up and Coming
    February 18, 2014
    I have the same problem. I tried changed my player height and IPD in the OculusConfigUtil, but it is not having any effect in my game.
    GA-Z97X-gaming gt; i5-4670k; Nvidia780Ti; 16GB PC3-17066; win7-64 bit; DK2
    Up and Coming
    February 18, 2014
    Agree that a) you should use 1 = 1 meter as much as possible, and b) Oculus should have a 'world scale' setting that would affect all Oculus-related parameters to bring things into proper scale. Ex: Just try modeling our Solar System at 1:1 scale. Not with 32-bit anything. Same deal with molecular modeling. These are just 2 very extreme examples, but you get the point. It also would make it easier to change effective size from 'ant' to 'giant'.
    Up and Coming
    February 19, 2014
    To avoid hassling with objects scale, I just hacked the "scale" property into OVRController. Comments say they had such intent but it wasn't there at the moment. Luckily it was really simple. Precisely what I've changed:

    bool ConfigureCamera(ref Camera camera, float distOffset, float perspOffset, float eyePositionOffset)
    {
    //
    camera.GetComponent<OVRCamera>().NeckPosition = NeckPosition * worldScale;
    camera.GetComponent<OVRCamera>().EyePosition = EyePosition * worldScale;
    //
    }


    And this simple hack did the trick. I didn't messed around with interface files and instead just deleted them, so you WON'T SEE this additional variable in the OVRController inspector window, unless you also delete interface files. All they do frankly is make it look slightly nicer by adding separators and hiding bunch of crap, so they kinda useless anyway.
    Up and Coming
    February 19, 2014
    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?