Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Axis rotation, Blender vs Unity

Discussion in 'General Graphics' started by blizzy, Mar 20, 2015.

  1. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I'm wondering what the recommended workflow is between Blender and Unity. In Blender, the Z axis is pointing up, while in Unity, the Z axis is pointing forward. So Y and Z are swapped.

    So now when I construct something in Blender and import that into Unity, the thing will lay on its side. I can either rotate the object in Unity, or rotate it beforehand in Blender. I don't really want to rotate it in Unity to keep things clean, so it looks to me like pre-rotating it in Blender is the way to go. Of course this gets a bit tedious the more objects you have.

    Is there any other recommended option? Perhaps an editor script that can massage the mesh vertices after importing so that the object is upright again without rotating the object in Unity?

    Partial solution: Turns out this was rather simple. See this Gist for a script and instructions.
    This MAY mess up UV mappings. I haven't tested that yet.
     
    Last edited: Mar 22, 2015
    PutridEx likes this.
  2. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    I always set X rotation -90 in Blender, use Ctrol + A and apply the rotation. Then, I export it to Unity, place the object on the scene, it will have X rotation -90, change it to 0 and do a prefab. You are good to go.
     
  3. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Actually I'd like to minimize work on this. Ideally it would be possible to just leave everything as is in Blender (no rotating), then import into Unity, create an object in the scene (which will be flat on its side), and then just press a button somewhere that uprights the object.

    I think I'll mess with a custom editor that shuffles around the vertices in the mesh. Should be fun!
     
  4. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I've managed to come up with a script that does exactly what I need. I've updated the OP with a link to the script.
     
    NomadKing likes this.
  5. brainchild-pl

    brainchild-pl

    Joined:
    Jun 6, 2013
    Posts:
    109
    Btw. how to set proper scale in Unity5, when importing from blender? I am really annoyed by it. In unity 4 I had NO problems. In unity5 I have no idea why the scale is wrong.
     
  6. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Hmm, my script does not seem to be a final solution, I'm afraid. A simple restart of Unity reverts all the meshes back to their original state. Which kind of makes sense since I don't think it imports the mesh from the Blender file and then copies it somewhere else. Need to dig some more.
     
  7. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    The best solution is to make sure the models are properly rotated in blender before exporting.
    Max artists have to do this as well.
    It gets a lot more complicated when dealing with characters, bones and skin.
    Best to orient the mesh before going into Unity, and before setting up animation rigs.
     
  8. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Yes, but then you constantly rotate back and forth if you plan to iterate on the models.
     
  9. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    No - you make sure the model is facing the correct direction and the axis is right upon creation. So then everything you do after that in the modeling application is oriented correctly.

    You probably thought I meant the last thing you do before exporting is rotate to conform in Unity. On the contrary the first thing you do after creating the object is orient it correctly and make sure the axis is correct.
    Iterate 100 times after that. The characters orientation in 3D software and Unity will match. :)
     
  10. kolbosa

    kolbosa

    Joined:
    Nov 3, 2013
    Posts:
    2
    Exprort FBX > Z forward > Check box "Apply transform"
     
    Last edited: Nov 20, 2015
    npatch likes this.
  11. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    That sounds interesting. I'll try that.
     
  12. Jim2018

    Jim2018

    Joined:
    Nov 17, 2018
    Posts:
    2
    One wonders why would blender do it this way?
     
  13. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,245
    PutridEx and npatch like this.
  14. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    227
    Excluding factors like preference and familiarity with one system, software that deals with geolocated data tends to use a Right Handed Z up coordinate system, just like AutoCAD in the picture above. Other examples are QGIS and Pix4D.

    Without being 100% certain on this and from what I remember, whether it's Projected Coordinates(meters) or Geographic(lat/long) usually get displayed in flat maps, so using Cartesian coordinates becomes intuitive, therefore Y+ points to North while X+ points to East and the origin is at the intersection of the Prime Meridian and the Equator.
     
  15. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    For a few years I'm thinking if it would be possible to have FUR (forward up right) coordinate system where math would be hidden behind and all software would be compatible.
    I wonder if it is just to hairy to implement.
     
  16. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
    Unity chose another option, that is definitely "the least correct".
    Left-handed for graphics and right handed inherited from physx for physics.