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

    sh0v0r
    Up and Coming
    January 12, 2014
    I have an interesting story to tell regarding this and Lunar Flight.

    When I first started my integration I was shocked to find out that all my assets had a scale of approximately 0.3 to 1.

    When I first dropped the the Player Controller into one of my scenes everything looked quite small.... a very disturbing thing to find out. :?

    The models were built to scale but I recall struggling in my early days (3 years ago) of learning to use Unity and getting models to import correctly with the right unit scale and up axis.

    So my solution to this was to modify the last line of SetCameraOrientation() in OVRCamera like this.


    // Adjust neck by taking eye position and transforming through q

    gameObject.camera.transform.position += q * (EyePosition * 0.305f); // Multiplied by mesh import scale (0.305) factor

    This effectively scales the neck modelling and IPD at the same time. You can modify this dynamically to create the effect of being shrunk or being turned into a giant, assuming you adjust the player height as well.

    The main issue for me is that all the HUD information regarding distances and speed are not relative to the scale, but Lunar Flight isn't intended to be a 100% accurate realism and for the most part this doesn't impact on the gameplay.
    Up and Coming
    February 18, 2014
    ThomasPasieka,


    I agree with using the 1 unit = 1 meter scale and this what I am doing.
    But all imported assets shouldn't be set with import scale to 1 ? Why then use 0.1 or 0.01 (default?) ?
    I am not very familiar with external modeling application but maybe in there people always create models with different scale ?
    Why are modeling tools not also using 1m units ?

    This links also to a problem I am facing, see the picture:
    photo.JPG
    The cube is 1 unit size (1m, imported with scale factor of 1).
    My eyes height is set to 15cm and still the cube looks so big ! Any idea why ?
    Up and Coming
    February 18, 2014
    1 meter is 3ds Max 2013 < 1 meter in Unity; still haven't found out what the exact scale is, which makes it a pain in the rear to create modular pieces for world / map building :\
    Current WIPs using Unreal Engine 4: Agrona - Tales of an Era : Medieval Fantasy MORPG
    Up and Coming
    February 18, 2014
    Exporting from Max is an art form in itself.

    Just make sure that your modeling environment is always the same scale, you create everything at the same scale, then export it all in the same scale. At that point you can confirm that all models are consistent to a relative size and changing the import settings to the appropriate value in Unity is all you have to do.
    Brevis / DevBlog Twitter
    Up and Coming
    February 18, 2014
    So far I've gotten the scale in Unity down to the 4th or 5th decimal place, but it's still not correct (which still makes it impossible to grid snap).

    I'm probably going to hop onto the Unity forums to ask for guidance on this :|

    edit: Another day, another dollar - it finally works. I neglected to set up the system units :roll:
    Current WIPs using Unreal Engine 4: Agrona - Tales of an Era : Medieval Fantasy MORPG
    Up and Coming
    February 18, 2014
    "saviornt" wrote:
    So far I've gotten the scale in Unity down to the 4th or 5th decimal place, but it's still not correct (which still makes it impossible to grid snap).

    I'm probably going to hop onto the Unity forums to ask for guidance on this :|


    What do you mean still not correct? At 1 unit = 1 meter 5 decimal places is an excess of accuracy unless your character is a real scale flea.
    Brevis / DevBlog Twitter
    Up and Coming
    February 18, 2014
    Did you guys experience the same issues as explaine din my post : eyes height not matching your unity dimensions ?
    As I said, eyes height at 1m seems to be much higher than the 1m cube in my scene..
    Any ideas ?
    Up and Coming
    February 18, 2014
    The cube is 1 unit size (1m, imported with scale factor of 1).

    Try creating a normal cube inside of unity that is 1 unit. If it's correct scale, there might be an issue similar to what I had (configured the units setup to 1 unit = 1 meter, but the system units where at 1 unit = 1 inch) which can have frustrating results.
    Current WIPs using Unreal Engine 4: Agrona - Tales of an Era : Medieval Fantasy MORPG
    Up and Coming
    February 18, 2014
    saviornt, what do you mean by 'configured the units setup to 1 unit = 1 meter' ? In Unity ? I think Unity does not matter of meters, only units. So I guess you are talking about the modeling software ?

    In my case, I created a 1m cube in Sketchup and exported as fbx. Scale was meters during export.
    I imported this cube inside my building in Unity and it is in line with the surroundings: furniture, building part,etc...
    Only the eyes height of my OVRPlayerController seems much taller than specified (as on my picture).

    One explanation would be that both my cube and my building are not sized correctly. But this does not hold with the following: on my picture, the eyes height is set to 15cm. But you can see on the picture that it is much higher (normally the camera would be pretty close to the floor).
    --> is I set my eyes height to 1cm, I should have it very close to the floor, but it does not... any ideas ?
    Can you maybe try on your side ?
    Up and Coming
    February 18, 2014
    "saviornt" wrote:
    The cube is 1 unit size (1m, imported with scale factor of 1).

    Try creating a normal cube inside of unity that is 1 unit. If it's correct scale, there might be an issue similar to what I had (configured the units setup to 1 unit = 1 meter, but the system units where at 1 unit = 1 inch) which can have frustrating results.


    Scale in Unity is accurate, discrepancies happen when the exporter program isn't setup properly. Thats why you have to go check all of the settings and get it to import correctly, then just continue doing it with that same setup for consistent results.
    Brevis / DevBlog Twitter