Rotation Sequence

I have a problem in specifying the angles of rotation for a transform in UNITY.

My source dynamics code that derives motion for an object calculates the conventional heading, pitch and roll (HPR) of the object, in that order. However, I understand that the Unity transformation applies a different order for the rotations.

Is there a simple, direct piece of code somewhere that will correct for the order of the rotations in the transformation?

Quaternion.Euler should work. It works for me in 3 axis.

You must set transform.eulerAngles (or localEulerAngles) one axis at a time, in the order you want. Unity order is z first, x, then y (see eulerAngles). You can use a different order, like this:

  transform.eulerAngles.x = angleX;
  transform.eulerAngles.y = angleY;
  transform.eulerAngles.z = angleZ;

The object will rotate x first, y, then z in this case. Keep your angles in variables like angleX, angleY and angleZ, and update eulerAngles when any of your angles change.