Euler Data and 360 3D Rotation

Hey guys, hope you can help me with a problem.

I’m getting from a motion sensor data in the YAW PITCH ROLL format.
I want to animate a cube that is rotating like my sensor (360 in all directions).

I used this code already:

var newRot : Quaternion = Quaternion.Euler(Vector3(mpu6050_y,mpu6050_z, mpu6050_x));
Bird.transform.rotation = newRot;

It works fine when I move in one of these directions. But not when i combine the axis.

Does somebody have an idea?

Yes, you’re probably doing the rotations in the wrong order.

I noticed that you’re passing y, z, x instead of x, y, z. This could be just because your mpu labels the axes differently. But if that’s the case, then the order that Quaternion.Euler combines these won’t necessarily be the same as what this device does. So, you’ll need to combine them manually, in the right order, something like:

Bird.transform.rotation = Quaternion.Euler(0, 0, mpu6050_x)
    * Quaternion.Euler(mpu6050_y, 0, 0)
    * Quaternion.Euler(0, mpu6050_z, 0);

If you’re sure each of the individual axes is correct, then you just have to find the right order to multiply them in… try all six possibilities if necessary.

Hey JoeStrout, sorry for the late reply. Thanks for that I will try it out!