Comments and answers for "Is there no way to get reliable angles from a rigidbody?"
http://answers.unity.com/questions/696203/is-there-no-way-to-get-reliable-angles-from-a-rigi.html
The latest comments and answers for the question "Is there no way to get reliable angles from a rigidbody?"Comment by JanusMirith
http://answers.unity.com/comments/768290/view.html
I totally understand the frustration, there are a lot of solutions for tracking the Euler angles of a object you are modifying, but nothing reliable to go the other-way.
I am dealing with hingeJoints that take a angle as an input and there seems to be no way to get or track the rotation of a transform without horrid issues.
You are not alone :(Mon, 11 Aug 2014 03:59:57 GMTJanusMirithComment by fafase on fafase's answer
http://answers.unity.com/comments/697943/view.html
You can convert quaternion to euler and vice-versa using
Quaternion.Euler(euler angle in vector3)
Quaternion.eulerAngles = new Vector3();
Now there is also a correspondance between quaternion and euler, it is no magic, so if you want to work your own: http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles but it is waht those two previous methods are doing.
To be honest, I don't really understand your issue, maybe a clear situation would help finding a solution. $$anonymous$$aybe there is a simple way to achieve what you are after but you may be going the wrong direction.Wed, 30 Apr 2014 15:56:22 GMTfafaseComment by robertbu
http://answers.unity.com/comments/697892/view.html
A few days ago for a question about a HUD display for a plane, I worked out some code for Heading (Yaw), $$anonymous$$ch, and Roll. The code is only lightly tested, and I have not tested it in conjunction with applying angular velocity of a Rigidbody, but it might be helpful for you:
[http://answers.unity3d.com/questions/696271/how-create-modern-aircrafts-hud.html][1]
[1]: http://answers.unity3d.com/questions/696271/how-create-modern-aircrafts-hud.htmlWed, 30 Apr 2014 14:21:54 GMTrobertbuComment by Clonkex on Clonkex's answer
http://answers.unity.com/comments/697861/view.html
@Owen Reynolds I have **no** idea what you actually mean (what's a built-in?), although I've been racking my brain for clever alternate ways of achieving what need, and the idea of using position to find angles independent of stored rotations seems like a good place to start. Besides, your method would create a Quaternion, the very thing I'm trying to avoid, as I need Euler angles to calculate torque to apply to a rigidbody.Wed, 30 Apr 2014 13:38:03 GMTClonkexComment by Owen-Reynolds
http://answers.unity.com/comments/697334/view.html
The only time I apply rotational torque is when I think the object may be blocked by something, and _need_ physics to prevent overlap. The math is a pain. Otherwise RotateTowards works fine (in a restricted area, it can force long objects to spin through walls.)
Otherwise I think a lot of people use joints, which compute the torque, etc... for you.Like connecting the front of your object with a spring to an empty always in line with the target.Tue, 29 Apr 2014 16:47:03 GMTOwen-ReynoldsComment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/697327/view.html
I have the most luck using a combination of Quaternions and "facing vectors." For example, `transform.forward` is the way you're facing, and `target.position - my.position` is the way I want to be facing. Then a built-in can give you the angle (Quaternion) between them. But that takes practice and a trig review.Tue, 29 Apr 2014 16:39:37 GMTOwen-ReynoldsComment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/697324/view.html
Yes and yes. It's like someone who might tell you the time as 10:45, then a minute later as "14 to eleven." But, I've never seen anyone extract all three Euler-angles as a whole and do anything useful with them.Tue, 29 Apr 2014 16:34:48 GMTOwen-ReynoldsComment by Scribe
http://answers.unity.com/comments/697084/view.html
what are you reading the rotation from? is it just the rigidbody.rotation or is it some kind of rotational speed? If you are using AddTorque like you mentioned in a comment, it doesn't take a rotation, it takes an axis to rotate around I believe so you may want to use Quaternion.ToAngleAxis or whatever it is.Tue, 29 Apr 2014 09:46:26 GMTScribeComment by Clonkex on Clonkex's answer
http://answers.unity.com/comments/696878/view.html
1st paragraph: I know, I know...I'm sorry, I didn't mean to be so angry in my question, I was just frustrated (which is no excuse). I mean, there's no way to get the Euler angles out of a rigidbody. I just would have thought someone would have come up with a better solution for rotations by now, given they are so important in games. If they insist on using Quats internally (which _does_ make sense, of course; Quats are a great way to represent rotations), then they need to make the rest of their commands Quaternion-compatible. That is, I need to be able to input a Quat into `RigidBody.AddTorque()` to push physics object around.
2nd paragraph: Yeah...I feel like I should just give up on my project because apparently it's physically impossible to get consistent results from `rotation.eulerAngles`... I really have no idea what else to do.
3rd paragraph: I have **no** idea what you just said there... ;)Tue, 29 Apr 2014 01:08:04 GMTClonkexComment by Clonkex on Clonkex's answer
http://answers.unity.com/comments/696876/view.html
@Owen Reynolds Wait, what? Are you saying the angles are reliable if you extract all three at once using `rotation.eulerAngles`, or are you saying that while the resultant rotation is identical, the individual parts of the Euler may change randomly?
@homer_3 I apologise for being so rude. I was just frustrated that there was no possible way to actually use the rotations stored in the rigidbody. So...I apologise.Tue, 29 Apr 2014 00:59:35 GMTClonkexComment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/696716/view.html
homer_3: the issue happens when you try to look up and use things like `transform.rotation.euler.x` and get a "random" result. It's a very common problem here.
To see it, take an unrotated object and tip it forward (around x.) You'll see that after x hits 90, y and z flip to -180 and x starts going _back to 0_ from 90. Typing in (110,0,0) works, but snaps to (70,-180,-180) if you move a tiny bit. So for that angle, euler.x is 70 or 110, depending.
This is why the docs say not to read or set just one eulerAngle.Mon, 28 Apr 2014 19:07:18 GMTOwen-ReynoldsComment by homer_3 on homer_3's answer
http://answers.unity.com/comments/696423/view.html
You asked
> Is there really no way to get reliable
> Euler angles from the rigidbody?
And there is, using the API I linked.Mon, 28 Apr 2014 12:32:22 GMThomer_3Answer by Owen-Reynolds
http://answers.unity.com/answers/696266/view.html
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.)Mon, 28 Apr 2014 05:39:28 GMTOwen-ReynoldsComment by Clonkex on Clonkex's answer
http://answers.unity.com/comments/696236/view.html
Why did you post that? The problem is not getting Euler angles from Quaternions, the problem is getting them reliably. I did _say_ that in my question...Mon, 28 Apr 2014 03:56:36 GMTClonkexAnswer by homer_3
http://answers.unity.com/answers/696207/view.html
https://docs.unity3d.com/Documentation/ScriptReference/Quaternion-eulerAngles.htmlMon, 28 Apr 2014 03:13:05 GMThomer_3