This is the script which is attached to the door:
public class DoorRotLimit : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Debug.Log(transform.localRotation.eulerAngles.y);
}
}
When I rotate the door around the Z-axis, the code is telling me that the eulerAngles.y is changing not z.
I’m not sure what is going on…
Also, the door’s local coordinate system seems to have Blender’s with the Z-axis pointing up.
I’m not sure if this is the problem, and Unity thinks that this is the Y axis.
Check the following video where I rotate the door and check the inspector transform and the console log.
I think I figured it out. I believe it was indeed because the objects keep blenders coordinate system, and I found out that I should always wrap imported models inside an empty game object and use that to apply transformations. Is this correct?
Part of the problem you’re running into is that Blender and Unity (infamously) use different coordinate systems. There’s a little more to it than “Unity calls up ‘Y’ and Blender calls up ‘Z’”. Blender uses a so-called “right-handed” coordinate system. Unity uses a “left-handed” coordinate system. It’s like the difference between these two pictures except that Blender also switches the Z and Y axes from the right-handed image:

One workaround is to wrap things inside an empty GameObject as you have done.
Another workaround is to simply accept that the coordinate system will be a bit different upon importing. Go back into Blender and adjust your model until it is oriented properly when imported into Unity. Then you won’t have to have your object rotated 90 degrees off-axis as you have in your video for it to look right. After doing that a few times you’ll get a good idea of how models will look when imported into Unity from Blender.
1 Like