- Home /
How to get rigidbody local z axis rotation in Euler angles?
Context: I have a rigidbody that I am rotating using addRelativeTorque() around its local axes. It is NOT kinematic and I am only manipulating it using physics.
Question: How to get Euler rotation in degrees around Z axis for this rigidbody?
Already tried: Currently I am using rigidbody.rotation.eulerAngles.z. However, conversion functions provided by Unity like this rotation.eulerAngles.z directly returns one of the combinations of Euler angles for the current Quaternion rotation. I know that when converting from Quaternion to Euler angles there might be multiple representations of Euler angles for a single Quaternion rotation. But there should be a proper way to get current rotation in degrees around some axis of the rigidbody, right? My current method, which is rigidbody.rotation.eulerAngles, does not work properly because when rigidbody is rotated beyond 90 degrees in X axis, it's Y and Z axis is being flipped to 180 degrees from 0 and If I continue rotating, X degrees is decreasing after 90 degrees. And again I know that it is due to Quaternion to Euler conversion. Storing my own Euler vector3 to keep track of the rigidbody rotation is also not possible because I am using physics functions to manipulate its' rotation. I am curious how other game developers are getting rotation of rigidbody around some axis in Euler and in degrees.
Big thanks in advance
Your answer
Follow this Question
Related Questions
Alternative to Quaternion.LookRotation() ? 2 Answers
Why can't I assign a rotation to a rigidbody Object? 1 Answer
How to get Angle float of specific axis.(Turret clamping related). 2 Answers
When applying a 90 degree rotation to Euler Angles, it is over/undershooting sometimes.. 2 Answers
Point Object Towards X/Z Position 1 Answer