Search Unity

Strange rotation behavior on rig: Rotation in Inspector isn't local rotation?

Discussion in 'Editor & General Support' started by dgoyette, Jun 3, 2020.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I have a rigged character with various bones, built in Blender. I'm experiencing some odd behavior when rotating the bones in Unity.

    For example, here's part of the model's hand:

    upload_2020-6-3_16-10-56.png

    That upper bone sticking up is used to spin the round thing at it's base. If I rotate that bone on the "y" axis in Blender, it properly rotates around the bone's local y-axis, and causes that round thing to spin proper. However, after bringing the FBX into Unity, the rotation seems all messed up.

    Here you can see the same part of the hand, with that some bone selected:

    upload_2020-6-3_16-12-52.png

    I have Unity set to display the transform gizmo using local angles. And yet, if I use the inspector to adjust the y-axis component of the rotation, it doesn't rotate around that local axis. Instead, it weirdly rotates around some axis which isn't quite any of the local axes for this bone:

    upload_2020-6-3_16-14-48.png

    Note that I can use the rotation gizmo to rotate properly:

    upload_2020-6-3_16-15-15.png

    If I click and drag on the green circle, it rotates correctly. But if I just adjust the y-component of the rotation in the inspector, it's not doing local rotation.

    Here's me rotating that bone via the rotation gizmo. Note that all of the transforms components change when I do this:

    Rotation.gif


    Does anyone know what would cause this?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    I know it's not super helpful, but the term "gimbal lock" comes to mind. it seems like there are already non-zero X and Z rotations in the euler angles, so you won't get a clean rotation from rotating y alone. Same thing happens with a lonely cube in an empty scene with nonzero X and Z rotations already set. Try it out! The rotation Gizmo uses Quaternion operations which are able to get around gimbal lock through the wizardry of complex numbers.

    Are you just trying to get the thing rotated properly in the inspector, or are you having problems from code too?
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    Yeah, I was just trying to do a sanity check, and try this out with other models I have access to, and it's pretty consistently not what I had expected. It had seemed to me that any time I rotated via euler angles in the inspector, I could expect the object to rotate on its local axes. But I must have developed that incorrect intuition on simple objects that didn't already start out with a complex rotation.

    The reason for the question is that I simply wanted to spin the object via an animation clip, and I had planned to set the euler angle rotations on that bone in the clip. But I guess I have other options, such as just recording the rotation using the rotation gizmo, or using the different code-based approaches to rotate around its local "up" axis.

    So, I guess I'm all set. I originally thought there was something wrong with my model, but now I see it's just that my expectations around this kind of rotation were just bad.
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Yeah the way to go is record the rotation for the animation clip with the rotation gizmo! I actually got a little confused with how easy it was to introduce gimbal lock in an isolated scenario due to this thread. I went and watched a refresher video:
    it's pretty good!

    I forgot about the whole "hierarchy" of rotations thing with Euler. I believe Unity is an x < y < z model, which means you can't really have gimbal lock around the z axis.