Comments and answers for "localEulerAngles don't seem to work in an equasion"
http://answers.unity.com/questions/292793/localeulerangles-dont-seem-to-work-in-an-equasion.html
The latest comments and answers for the question "localEulerAngles don't seem to work in an equasion"Comment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/293670/view.html
Thanks for bearing with my new-happy bug-ridden reply -- fixing my "answer."Tue, 31 Jul 2012 15:12:12 GMTOwen-ReynoldsComment by ronald.meijers on ronald.meijers's answer
http://answers.unity.com/comments/293431/view.html
Thanks for the explanation!
But I'm getting: The nested type `Euler' does not exist in the type `UnityEngine.Quaternion'.
Edit: Removed the 'new', now it rotates, but at ridiculous speeds, trying to fix that
Edit2: Alright, I needed to use transform.localRotation ofcourse :)Tue, 31 Jul 2012 06:12:22 GMTronald.meijersAnswer by Owen-Reynolds
http://answers.unity.com/answers/293054/view.html
Any given eulerAngle is unstable -- like someone saying the time is 20 past noon, then a minute later saying it's 39 minutes to one, then next minute going back to 22 past noon. Looking at just euler z is like looking at the minutes "randomly" snapping from 20 to 39 to 22. The docs mention this, sort of -- they say not to read/set just one (you're reading only z.)
Euler angles tend to only snap around 90, 180, 360. So, you figure can work around that. But the more ways you move, the more you'll get new snaps later.
The trick for setting with eulers is to "pull out" your angle variables, which keeps them consistant:
float zAng; // global
zAng=Mathf.MoveTowards(...);
// The official way to set a rotation from x,y,z rotations,
// instead of setting EulerAngles= :
transform.localRotation = Quaternion.Euler(0, 180, zAng);
// (^^ EDIT -- fixed based on comments ^^]
if(zAng==180) ...
The idea here is that `zAng`, being your variable, will never do anything strange. Unity may still set take (0,180,90) and rewrite it as (-90,90,0) -- same facing but diff numbers. Before, that would have made you start over at 0. Now it won't.Mon, 30 Jul 2012 15:37:24 GMTOwen-ReynoldsAnswer by ronald.meijers
http://answers.unity.com/answers/292851/view.html
Thanks, that seems to be somewhat the same as what I got now:
<pre><code>
if(Mathf.RoundToInt(transform.localEulerAngles.z)==180)
{
print ("Rotation completed");
}
</code></pre>
Although that means it loses it's accuracy with tenths of degrees.
Luckily I can get away with that in this project, but for future purposes I might want a perfect acurate solution. Too bad I suck with Quaternions :PMon, 30 Jul 2012 09:35:24 GMTronald.meijersAnswer by ScroodgeM
http://answers.unity.com/answers/292842/view.html
<pre>if (Mathf.DeltaAngle(180, transform.localEulerAngles.z) < 1f)
{
print ("Rotation completed");
}<pre>
</pre></pre>Mon, 30 Jul 2012 08:58:03 GMTScroodgeMComment by ronald.meijers
http://answers.unity.com/comments/292838/view.html
Alright,
I did find a sloppy workaround using Mathf.Round, to round the angles in the equation to an integer, which seem to 'solve' it for now.Mon, 30 Jul 2012 08:39:36 GMTronald.meijersComment by Kryptos
http://answers.unity.com/comments/292821/view.html
Changing the values of localEulerAngles or eulerAngles at runtime is not a very good idea (especially when you have one or more values that are close or equal to a multiple of 90 degrees). You should consider using Quaternion instead.Mon, 30 Jul 2012 08:03:06 GMTKryptos