Ananki Game Studio

Blender FB”X-files”: Blender FBX to Unity

Are scale and rotation issues causing you headaches when exporting FBX from Blender to Unity? I know the feeling. Hopefully this guide can help clean up your messy transforms!

The guide consists of 4 parts; A quick runthrough of the unit systems in Unity (1) and Blender (2), and then a couple examples on ensuring correct scale (3) and rotation (4) when exporting FBX from Blender.

Prerequisites

Blender 2.79 from https://www.blender.org

Unity 2018.1 from https://www.unity3d.com

1. Unity units

One of the most important things to consider when making models in Blender for use in Unity is the unit systems. This is one of the weaker links between Blender and Unity and can cause major headaches if set up incorrectly.

Allthough both softwares handle 1 unit as 1 real world meter, the Blender FBX exporter will not provide Unity with this information “out of the box”. Since you are reading this you’ve probably experienced that your Blender model has a scale of 100 when imported to Unity. Though I am not entirely sure of the logic behind this, it is related to the way Unity reads the File Scale from Blender (any insight to this is welcome in the comment section!):

UnityCubeImportSettings

Ideally, all imported objects should always have a transform scale of 1, and all rotations set to 0.

Luckily, there is a relatively easy way to fix this in Blender.

 

2. Blender Units

First, let’s cover some basics regarding the unit system in Blender. As a rule of thumb it is always a good idea to model objects based on real-world dimensions, i.e. having 1 unit = 1 meter. That saves a lot of trouble, especially when collaborating on a project with other people. As an example we’ll just use a basic shape; the cube. Unlike Unity, where the standard cube has a scale of 1 and a size of 1 unit, the standard Blender cube has a Scale of 1, but it has and actual size of 2 units:

TransformNoUnitPreset

It can be a bit more convenient to have your dimensions shown as metric units. This can be changed in the Properties panel, under Scene-> Units:

Blender Units Undefined

Change from “None” to “Metric”:

Blender Units Meters

Now everything within Blender will be calculated in Metric units. (Be aware that the “Unit Scale” field now overrides all global unit settings. Changing this value can stir things up, so I recommend keeping this at 1.0 units (unless you know what you are doing)! For instance, changing this to 0.001 (i.e. 1 Millimeter) will set the End Clip distance of the viewport and camera to only 1 meter, which can be really annoying if you don’t know why it’s happening!)

So, with Metric units and Unit Scale = 1, the Dimensions of the cube is now clearly two meters:

TransformMeterUnits

The Dimensions parameter is an awesome feature in Blender, but it is important to be aware of the Scale/Dimensions relationship. Changing the Scale changes Dimensions, and changing Dimensions changes Scale.

Cube Scale set to 0.5 changes Dimensions to 1:

ScaleWhenChangedDimensions

Whenever you change one of these it is always a good idea to “Apply scale” (Ctrl+A). This ensures the Scale value is always 1:

ApplyScale

Scale applied:

ScaleWhenApplied

Allright, now that we have covered the basics of the unit system in Blender, it is time to look at the export settings.

 

3. FBX exportcorrecting Scale

Select File->Export->FBX:

SelectFBX

These are the default FBX export settings:

Blender Export Settings raw

There are a lot of options here, but for the purpose of this guide, there are only a couple settings you need to consider.

If you only want to export the objects you have selected, check “Selected Objects”, otherwise leave this unchecked:

Blender Export Settings Selected objects

Then make sure the button next to “Scale:” is unpressed (the blue top hat with arrows left and right):

TopHatButton

Then change the “Apply Scalings” field from “All Local” to “FBX Units Scale”:

Blender Export Settings Apply Scalings

Export the file into your Unity assets and check the import settings. The object should now have the desired File Scale and transform Scale:

UnityCubeImportSettingsCorrectedScale

However, there is one last issue; the X-rotation is still -89.98. This is due to Blender using Z as the upwards axis, while Unity use Y. Unity then compensates by rotating the X-axis. This looks messy and can be problematic, especially if you are going to rotate the object through scripting. As far as I know there is no perfectly elegant fix for this, but there are a few “half-dirty” options that will do the trick.

4. FBX export – correcting X-Rotation

So far I’m aware of three possible solutions for correcting the X-rotation of Blender exports:

Option 1: Not really related to exporting, but nevertheless a way to do it; Simply parent the imported object to an empty gameobject in Unity, as described in the Unity manual: https://docs.unity3d.com/Manual/HOWTO-FixZAxisIsUp.html

Option 2: There is a feature in the exports settings with the hacky name “!Experimental! Apply Transform”. This seemingly works well and sets rotation values at zero in Unity, but as the name suggests this is indeed still at an experimental stage. I would only recommend this for simple static objects as it does not work well with armatures or other more complex hierarchical setups from Blender. Use with caution!

Blender Export Settings Experimental

Option 3: In my opinion the best approach; In Blender, simply rotate the object -90 degrees in the X axis, apply rotation (Ctrl+A), then rotate back +90 degrees and export. While still not 100% ideal, I consider this to be the easiest solution.

Thats it!

Remember to save often, make backups and last but not least – enjoy making games!

Questions? Suggestions?! Complaints?!? Please leave a comment and let us know!