Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

# Improvement(?)

See original GitHub issue

Thank you very much for this addon, it really makes with importing Blender models into Unity a lot easier!

While all the individual object’s positions and rotations are correct, it seems like I still need to rotate the whole model by 180° on the Y-axis in Unity to make it face in the right direction.

So I tried making a fix for it (the comments in the code should hopefully be self explanatory, although I am not 100% sure about why some of my code segments seem to be required for it to work correctly). Maybe there is a better way, but this seems to work in all scenarios I tested (including more than one child object).

This is the code starting from line 130. I have also attached the full file below (although as .txt, as .py files are not supported for uploading in this case):

``````# Reset parent's inverse so we can work with local transform directly
reset_parent_inverse(ob)

# Create a copy of the local matrix and set a X-90/Z-180 matrix
mat_original = ob.matrix_local.copy()

rot_x = mathutils.Matrix.Rotation(math.radians(-90.0), 4, 'X')
rot_z = mathutils.Matrix.Rotation(math.radians(-180.0), 4, 'Z')

ob.matrix_local = rot_x @ rot_z

# Apply the rotation to the object
apply_rotation(ob)

if (ob.parent):
# Reapply the previous local transform with an X+90 and Y+180 rotation
ob.matrix_local = mat_original @ mathutils.Matrix.Rotation(math.radians(90.0), 4, 'X') @ mathutils.Matrix.Rotation(math.radians(180.0), 4, 'Y')
else:
# Reapply the previous local transform with only an X+90 rotation
ob.matrix_local = mat_original @ mathutils.Matrix.Rotation(math.radians(90.0), 4, 'X')

# Correct position by inverting X and Y values
loc_or = ob.location
ob.location = (-loc_or.x, -loc_or.y, loc_or.z)

# Correct rotation by inverting Y value
rot_or = ob.rotation_euler
ob.rotation_euler = (rot_or.x, -rot_or.y, rot_or.z)
``````

Hope this helps and of course please let me know if you have any suggestions or if there might be a better way!

blender-to-unity-fbx-exporter.txt

### Issue Analytics

• State:
• Created a year ago
• Comments:6 (3 by maintainers)

#### Top GitHub Comments

1reaction
Kai764commented, Jun 28, 2022

Thank you for this graph, I didn’t know the coordinate systems were that arbitrary…

Personally, Z forward, Y up and X right makes the most sense to me, like Unity or DirectX have it. Unreal also seems good enugh to me, just with Y forward and Z up. But for the rest it looks a bit unintuitive to be honest.

I guess you have to make the best out of it, and at least your addon will work without any problems then.

0reactions
EdyJcommented, Jun 28, 2022

Pretty much every 3D software out here arbitrarily chooses their coordinate system and the meaning of each axis. Here’s an (incomplete) example:

Read more comments on GitHub >

#### Top Results From Across the Web

Improvement Definition & Meaning - Merriam-Webster
The meaning of IMPROVEMENT is the act or process of improving. How to use improvement in a sentence.
Read more >
Science of Improvement: Testing Changes | IHI
Model for Improvement Once a team has set an aim, established its membership, and developed measures to determine whether a change leads to...
Read more >
Quality Measurement and Quality Improvement - CMS
Quality improvement is the framework used to systematically improve care. Quality improvement seeks to standardize processes and structure ...
Read more >
How to Begin a Quality Improvement Project - PMC - NCBI
The initial steps involve forming an improvement team that possesses expertise in the quality of care problem, leadership, and change management ...
Read more >
Shift Improvement Consulting
Shift uses improvement science to accelerate and amplify equitable change across many contexts.
Read more >

No results found

No results found

#### Troubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

No results found

No results found

No results found

No results found

No results found