Unity And Blender Files

Facebooktwitterredditpinterestlinkedinmail

Importing Blender Into Unity

Since I’m using Blender and Unity for my current projects, I’ve had to figure out a common problem with this integration.

Right-handed… left-handed… up is forward… forward is up… dogs and cats living together.

There are a bunch of posts about importing models from Blender into Unity, and how they always come in rotated incorrectly. Blender is right-handed with (right, forward, up) orientation, while Unity is left-handed with the (right, up, forward) orientation. The primary axes seem to be forward and up, since the objects rotate around the axis that bisects those two.

Basically, you want your Blender model to face forward along the z-axis and up along the y-axis. This causes your model to appear to be pointing up in the Blender workspace, which is not really how you want to work on things. Blender has the ability to distinguish between applied rotation and displayed rotation, which I use to fix this apparent problem.

After researching and experimenting, I’ve decided to use the following method. However, I have not attempted to animate any of my objects yet, so that may not work properly. If animations, or any other feature, breaks this method in the future, I will update this post to reflect the fix.

Blender Workflow

  • In Blender, create your model upright using (right, forward, up) orientation.
  • Rotate the model (-90, 180, 0) using XYZ Euler rotation.
  • Apply the rotation.
  • Rotate the model (-90, 180, 0) using XYZ Euler rotation.

This will apply the corrective rotation, which fixes the rotation in Unity. Then it uses the second rotation to make the object appear correctly aligned in Blender. It just so happens that the complementary rotations are equal, since it’s effectively rotating the object 180 degrees around the (0,0.7071,0.7071) axis.

You could also rotate the model using (0, 0, 0.7071, 0.7071) in quaternions, or (0, 0.7071, 0.7071, 180) in axis-angle notation. It’s up to you. Generally these are safer, since they don’t suffer from potential gimble-lock, but this rotation works fine in Euler angles.

I’ve found that as I join objects together, they remain properly rotated. I haven’t tried anything too complicated though, like multiple objects or joining to a non-rotated object. I’ll test those situations out soon and update this post with any findings.

Facebooktwitterlinkedin

One thought on “Unity And Blender Files

  1. I have found with Blender workflow that sometimes the easiest thing to do is to work in the default environment then write a custom export python script that leverages the generic export for the file format to create a custom export script for that environment.

    For example, a few versions back, I created a Panda-ized version of .3DS export that adjusted the namespace and the scaling on export.You can put it in the same directory as the other scripts whereupon it will show up on the add-ons menu.

    Another option is to write a script that is macro-like and does the rotation en masse, you can then put it in the toolkit with a keystroke by-pass.

    I am also currently playing around with Blender a lot… right now using .SVG files on import and on rendering in Blender. Sort of an Inkscape to Blender to Inkscape integration. SVG animations are incredibly powerful because they can be scaled arbitrarily without pixelation.

Comments are closed.