I apologize in advance, this is one of those questions where the answer is embarrassingly simple, yet I can't find it. But alas, progress trumps pride... I would like to get the current rotation of an object in xyz degrees, like you see in the editor, rather than the object returned by transform.rotation. How do I do this?
As the above link shows, you just have to check transform.eulerAngles.x for x, transform.eulerAngles.y for y, and transform.eulerAngles.z for z.
Code (csharp): transform.rotation.eulerAngles returns a Vector3. Use it as you like. ...err, nevermind. I had no idea that eulerAngles was a property of Transform. Nice! http://unity3d.com/support/documentation/ScriptReference/Transform-eulerAngles.html
I would like to get the current rotation of an object and feed it into another script, or another part of the same script, in an assortment of "If " statements to control different outcomes depending on the rotation on the Y axis. I'm struggling to find an answer but I'm not from a scripting background and struggling generally. Thanks chaps.
eulerAngles should work just as well in JavaScript as in C#, but why for the love of sanity would you still be using JavaScript in Unity in 2019? I'm honestly curious, you're the first person I've seen in years that's still on Javascript. Are you maintaining a legacy project that was created in 2009? If you're wondering why I'm so curious, I long ago (back when this was still actively debated on the forums, which was YEARS ago) wrote a long list of reasons why C# is objectively better, and I've yet to see anyone in the last decade make a good case for the other side. If you have some niche reason for using it I really, honestly would like to know what it is. I'm fascinated.
I'm glad you've awoken from your 3 year long coma. Welcome back https://blogs.unity3d.com/2017/08/11/unityscripts-long-ride-off-into-the-sunset/
ha ha ha NO! internet has no time, the rules always apply it doesn't matter if you write them after 1, 3, 10 years