Answers for "How to get Yaw? or How to get Angle between two vectors over 180?"
http://answers.unity.com/questions/1558320/how-to-get-yaw-or-how-to-get-angle-between-two-vec.html
The latest answers for the question "How to get Yaw? or How to get Angle between two vectors over 180?"Answer by hannacho700
http://answers.unity.com/answers/1558326/view.html
I omited some explanation. In my case, transform.up points his backside. So down means forward.
then I used "down.y =0" to bring vectors to xz plane.
So I can already get yaw based on left(-Vector3.right) in xz plane.
but It's range is -180~180.
so I want to get more big size of range.Mon, 01 Oct 2018 02:47:24 GMThannacho700Answer by JVene
http://answers.unity.com/answers/1558322/view.html
Let's be clear about one point in your question. There is no information that comes from vectors which can tell you how many times a rotation has been performed. If an object rotated 765 degrees clockwise in the xz plane, the only information you'll get back from the resulting information in a Transform will be that the object rotated 45 degrees clockwise, because that is all the information that remains.
----------
Vector3.Angle returns the angle between two vectors, without regard to any axis. If you define yaw as a rotation in the xz plane, there is no relevance to down or up. I would infer that a relationship to the world 'negative right' direction and the transform's 'down' direction is more that of a pitch than a yaw, but Vector3.Angle is going to return the angle between 'negative right' and wherever 'down' is pointing, which won't be relative to an axis. Imagine pointing your left hand straight out left (that's what negative right means, no?), then point your right hand ahead of you, but down from straight out 45 degrees. Now, in yaw (the xz plane), your arms are 90 degrees apart, but the angle between your hands will be somewhere less than 90 but greater than 45 degrees, in a plane at an angle not aligned with a reference to a yaw.
----------
You can get the rotation of an object (in the range of -180 to 180 degrees) using Mathf.Atan2, providing the coordinates you get from transform.forward ( x and z, ignoring y ). The return value is in radians which you can convert by multiplying the return by Mathf.Rad2Deg. Note, however, that the standard orientation may require adjustment to your expectations, because in math zero degrees (or zero radians) is on the X axis (to the right), and positive rotation is counterclockwise. Once you adjust that for your expectation, you'll get the angle in the xz plane the object is facing.Mon, 01 Oct 2018 02:01:59 GMTJVene