Hi all!
Lately I’ve been trying to tackle Blender’s python and here are early fruits of my experiments. This addon fixes rotation of objects such as meshes or armatures to match Unity’s coordinate system.
To install this addon unpack it to your Blender addon folder, e.g. “C:\Program Files\Blender Foundation\Blender\2.67\scripts\addons” or use install from file button in user preferences under addons tab.
After installing, addon is in Object category and after enabling it, can be accessed from Tool Shelf under “Unity Tools” panel.
Note that complete rotation fix on X and Z axis will swap object so it will face +Y axis instead -Y, if you export through fbx remember to set Forward Z and Up Y as export axis when you use full rotation fix.
Update:
I took a look over the addon since Blender properly entered version 2.8 already. I fixed a couple issues with origin point of objects not staying in their place while at it too and moved the panel to more appropriate place for this version. It’s on the right sidebar now, in Misc tab if you can’t find it. Let me know if you find any issues.
Bravo! I applaud anyone who offers their hard work for free to help deveopers with their work flow. I can’t wait to see what further developments and tools you create!
Hello, which is the minimum Blender version is requirement?
only from 2.67 ?
Becasue i tried with the Blender 2.63 version. Im just try to apply the plugin with a simple Cube which a default model in blender, and i get these error messages:
I’ve been messing with it for a while and it works if my object in blender is facing the negative Y axis.
Is this the intended behavior or am I doing something wrong?
Basically, models exported from Blender to Unity are flipped by 90 points on X axis, so if model is flipped by -90 points before export and rotation is applied then rotations cancel themselves and models are as they should be. This however means, that after you rotate your model, in Blender it will appear ‘laying’ on its back, so to make it look unchanged and workable it has to be rotated by 90 points on X axis, but without applying rotation, making its local Z axis face global -Y axis. This add-on automates this process.
This rotation is not needed, my add-on should produce only rotation of 90 on X axis and no other rotation should be needed to export correctly. Can you tell me which version of blender and exporter you use? And possibly send me blend file on which you found this problem?
Your script only performed the 90 rotation on X axis. I made that extra 180 Z rotation by hand (Rotate 180 in edit mode, and rotate again 180 in object mode, same trick that the script does with X).
If I don’t make that rotation objects end up facing Z positive. When I edit objects in Blender, like that plane, that are facing Y-negative in order to make them facing Z-negative in Unity I need to perform that rotation. In this way I’m changing only the Z-Y axis and not the object orientation according to X Axis.
My question was more on the way if you also make that rotation when editing in blender (not only you, other people who use your script). I can guess that you only perform the X rotation, but why not the 180 Z rotation?
It’s the only way I found to then reset the rotations in Unity (X: 0, Y: 0, Z:0) and end with my object facing the same directions in the scene. I also noticed that Unity tries to preserve some rotations, so I also need to reset them by hand.
When I started to do the rotation compensation trick in Blender I also started to rotate around Z. So now that I found a script to automate this I was wondering if other people is rotating around Z.
I don’t know how animations will be affected by this, only used it on “static” models for now.
No, I do not need any extra rotations for models exported from Blender. If you use fbx exporter check if your export axies match Forward -Z and Up Y, if they are not then this may cause your problem.
I simple place the .blend in the Unity assets structure and Unity performs the import, but I think -Z Forward and Y Up are the defaults, so no difference should result from this process.
I think that just compensating around X axis your model will end up rotated from your original facing direction.
I will try to generate another set of screenshots to state better my question.
Lets see if I can state my question this time. Again, your script is working perfect. I’m only asking why an extra 180 rotation around Z is not applied.
I modeled a “small arrow” and a “big arrow” to represent “Up” in an object and “facing” direction. “big arrow” is facing direction, “small arrow” is up.
In the example, both objects are reseted to 0 rotation on all axis when imported to Unity.
If I only apply the X correction we can see in the first example that the “Up” direction is preserved. Z-Up in blender is converted to Y-Up in Unity, and this is OK. But facing X positive in Blender now becomes facing X negative in Unity. If you are only interested in the “Up” correction this is fine. And in past projects I was only concerned about this.
In the second example, after the script applies the X correction I apply an extra Z correction. In this way, my object is also facing X positive (same as when editing) when imported to Unity.
My question was about this X facing problem. If you are also concerned about this issue, if it’s good to give a thought and introduce this extra Z rotation in the script. Again, I don’t know if this affects animations (I only tried it with not-animated objects). Just wondering if people also used to do this correction in blender or once the objects is in Unity (“Up” corrected) you don’t care the object is flipped around Z axis.
Ok, now I understand what the problem is. In Blender +X axis is left-sided where in Unity is right-sided. While rotating on Z axis will fix this, it will introduce new problem. From what I seen most people work with -Y axis as forward, should you apply Z rotation forward will switch to +Y and it will probably screw most peoples workflow.
Personally it doesn’t bother me, however, in my free time I will think about good way to update add-on to address this issue.