- Home /
Question by
Cal-Tek · Jun 12, 2019 at 03:45 PM ·
quaternionrollpitch
Get pitch and roll
Hello, I have a ship in the sea, I would like to find her pitch and roll respect her own axes. I am using the following code that I found in some other post but it doesn't seem to work
Quaternion q = Quaternion.Euler(myRigidBody.transform.eulerAngles);
roll = Mathf.Atan2(2 * q.y * q.w - 2 * q.x * q.z, 1 - 2 * q.y * q.y - 2 * q.z * q.z) * 180 / Math.PI;
pitch = Mathf.Atan2(2 * q.x * q.w - 2 * q.y * q.z, 1 - 2 * q.x * q.x - 2 * q.z * q.z) * 180 / Math.PI;
Note that I changed the reference system of my ship using as her father an object that has the transform rotation (-90,-90,0). Thank you
Comment