- Home /
How to make blender bones z axis forward in Unity
Hi. I do realize this might be more of a Blender than a Unity question, but I figured that this might be the right place to ask since people on the blender forum might not know the relation between Blender-Unity coordinate system.
My problem is that I want to easily be able to rotate bones on my character by using the LookAt function. Currently this is horrible since I have no idea how the axes on each bone are configured. There are currently two bones I want to rotate using LookAt.
In Blender, the bones both bones are pointing out of the arms, and what I want is for the z axis to always point forward, out of the arms in this case, the y axis to point up and the x axis to point right. I suppose that this is something that perhaps has to be done in Blender? Heres how it looks there.
I know that there are some configurations that can be made when you export as an .fbx in Blender, these have not helped with the bones though. The axes of the whole model are fine. Z points forward, Y up, and x horizontal. Here are my Blender export settings.
EDIT: I just realised that the picture above is an old one. The forward of my current export is actually set to Z axis, and not -Z axis. This makes the model's forward face the z direction in unity, but it does not help with the bones.
So there are no export settings to change the bone direction, like the .fbx export settings can change the model direction?
I don't use blender, and I am not a modelmaker anyway.
If you mean export settings in Blender I don't know, ask a Blender expert.
I'm fairly sure you have to just properly rebuild the model ... from scratch ... I've heard my modelmakers complaining about doing this constantly, there's no way around it.
(the SCALE issue is very similar .. it is true in unity import you can change the scale; but that sometimes is not a solution. with the "z forward" issue there's just NO way around it. all game production is z-forward.)
If this is the case, then the model will have to be redone. I guess i'm lucky to find out now and not later. :)
Okay, well I guess i'm lucky to find out now and not later. Thanks. :)
This isn't about modeling though . . . it's about rigging - the bone armatures themselves have a bizarre error when converting from blender's coordinate system (which is both z up AND right handed) to Unity's (which is both y up AND left handed).
I'm looking for a solution to this myself right now . . . it might be possible if you could manipulate the axes of the bones, but everything I've seen so far suggests that you can only adjust the bone roll - that the axis the bone is facing will ALWAYS be the local y axis in blender. THAT is the root of this particular problem.
This is probably super late for you, but maybe it'll help someone else. If you're relying on scripts to modify your bone rotations, you can create a quaternion that acts as a correction to the coordinate system, and multiply it to whatever rotation you want to transform your bone by, then multiply the result to the inverse of your correction quaternion. This is what I've been doing for my case thus far, and while it works fine, it'd be nice to find some way to correct the armature before it gets into Unity.
EDIT: Alternatively, you can just apply the correction quaternion directly to your forward, right, and up axes when you use them to calculate your resultant quaternions (and you don't need to multiply your results by the inverse afterwards). Whichever makes more sense / is easier to use for you.
Answer by Fattie · Apr 08, 2013 at 08:32 AM
Is what you're asking: you must model in z-forward. It's an absolute basic in video game production.
It's a pain, but the model would have to be redone.
There are silly workarounds, but they're silly. Every model you import in to Unity has to be z-forward
Even experienced studios screw this up sometimes: A good example is: on a car model, every little piece of the car, must be z-forward. For example with the left-right wheels/tyres, you cannot just flip-em arround, the right and left must be each individually z-forward.
Answer by Lugen · Nov 16, 2013 at 07:44 AM
For getting the mesh to align according to Unity axis just rotate it in Blender to face the right axis and then reset the transformation. Ctrl+ a is the default hotkey.
Not entirely related to your problem I know but I had to mention it since the comments about rebuilding the model from scratch just sounded completely ridiculous.
Now I'm not sure about the armature itself as I'm looking into a similar issue myself. In my case I want to parent various objects to bones and have them match the orientation. So far I've only found the above mentioned workaround.
@Lugen: I was also fighting with parenting today (completely new to Unity and Blender), my became to add an extra bones for attachements.
$$anonymous$$y case was; I wanted to attach hair to the head but it ended up in the neck area because of how Unity works (wrong end of head bone).So I added a hair bone to the head that I could use to manipulate the position ;)
The benefit with these extra bones is that we can parent objects to the skeleton while manipulating the child and not affect the parent. Example, I can now spin the hair around or make it jump around without manipulating the head bone.
Answer by bidjo666 · Jul 15, 2020 at 06:40 PM
In FBX export settings select Armatures Primary Bone Axis select Z Axis Secondary Bone Axis select -X Axis
Answer by vladibo · Jul 02, 2016 at 09:59 PM
I have found that modifications on model level are too labor intense and the cost of wrapping it with artificial parent transform is too small to be a problem, so I just wrap it in an artificial game object
var currentHolder = new GameObject(current.name+"_Holder");
var holder = currentHolder.transform;
holder.position = current.position;
holder.LookAt(holder.position + desiredWorldForward,worldUp);
holder.SetParent(current.parent);
current.SetParent(holder);