I need to get the current angles of a rigidbody so I can apply countertorque to keep it at a particular orientation. Is there really no way to get reliable Euler angles from the rigidbody? Unlike most of the rest of my game, I can’t simply keep the current angles in variable and modify them myself because the physics controls the rigidbody.
If there’s no way, then why not? It’s unbelievably frustrating that everything is stored as stupid Quaternions, when there’s no way to get Euler angles from them.
I can’t believe I’ve put this much effort into Unity for nothing.
EDIT:
I don’t mean “how do I get Euler angles from a Quaternion”, I mean “how do I get reliable Euler angles from a Quaternion”.
Unity didn’t invent Quaternions. It uses them because other game engines do, because they’re considered the best way to do 3D angles.
For real, there isn’t a 1-1 mapping between Quaternions and the YXZ “Euler” representation. When you pull out a Euler angle, there’s no way to know which of the 2(?) possible results you want. You can’t get consistent results, because of math.
You can project transform.forward onto planes and compute using trig. Of course, you’ll get huge snaps if the object faces the main axis (this is what Quaternions avoid.) Easier is just to do everything in Quaternions. Save the wanted facing as a Quaternion, and figure out how to push from one Quat to another (I use X-product of their “forwards”. Oddly, it works as angular velocity numbers.)