[60746-localangularmomentumexperiment.zip|60746]@FogSight I’m pretty sure I do have an answer for you. I was searching for it too, and now I’ve got it (with proof!).
I want to add that the code above does not work. I have worked my own solution though:
Vector3 localAngleVelo = experimentalShip.transform.InverseTransformVector(experimentalShip.GetComponent<Rigidbody>().angularVelocity);
That code will get you the local angular velocity of your object. The code posted by RavenBlack only gets you the same value you put in.
I’m 90% certain what I’ve got is right. I just tested it in Unity, by printing the values of both the Rigidbody angular velocity (which is in world space) and the result of this code. I used AddRelativeTorque to add to my rotation, so when I did rotate it would be added locally.
Fact: One cannot rotate on more than one axis. However to have something to refer to we need some local axes. World space is always the major reference, Ie. the rotation/position/scale of everything else is based on it. When we rotate something, then the axes local to our object change their orientation in world space. In order to apply torque (rotational velocity) to our object we must know the relation from our local reference axes to world space. Otherwise if we rotated while not on a strict world space axis (ie. straight up/down on X-axis world space) then when we rotated on two axes the rotation would be applied relative to world space instead of locally to our object!
That would be like an aircraft being controlled by external controls rather than its own! Imagine a plane like that, it would be at the mercy of the winds!
The way that I tested this was: I set up my experimentalShip object to be controlled via AddRelativeTorque. That meant that when I wanted to rotate, then it was controlled from its orientation/reference axes than outside axes (like world space). I printed the result of this code and the angularVelocity of the experimentalShip object (which is in world space remember). When I rotated to an odd orientation, instead of on one axis I could see the difference between the local calculation and what the AngularVelocity values were.
I could see that when I applied rotation, the angular velocity values changed to reflect the objects world space rotation. The local angular velocity value that I printed was zero on the axes I knew I wasn’t rotating by, and non-zero on axes I knew that I was rotating by. So when I was rotating directly left to right from my point of view, but the object was actually oriented at an odd angle in world space, then the Y-axis value was non-zero, while Z and X were zero in my local value print-out!
This is all in Unity 5.3.0f4 .
I’m posting the project as proof-of-concept. Pay attention to the output in the console.