Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by camjackson89 · Nov 06, 2010 at 03:11 PM · rotationtransformangleeulerangles

Problems caused by non-unique Euler angle solutions

My title might not be accurate, if I'm not correct in guessing what's causing the problem here. I'm trying to get the Euler angles of an object (it's a plane/glider in a 2.5D sidescroller game) in a script to figure out its orientation, and also to determine force magnitudes (using sin and cos of elevations etc). The problem is that any given rotation doesn't have a unique solution as three Euler angles, and Unity doesn't always give the angles the way I want/expect.

For example, the plane has initial rotations (0, 90, 0), so that it's facing to the right of the scene. If I tilt the plane up and down in the scene view, its x rotation changes, as I'd expect, seeing as it's local x (/red/right) axis is pointing towards the camera. However, as I tilt it up past fully vertical (x=-90) so that it's pointing up and to the left in the scene, all of a sudden the y rotation flips to -90 instead of 90, and the x rotation starts coming back towards zero, instead of going past 90. You can check this pretty easily in the editor yourself. This makes it hard to work with Euler angles in code to figure out what's going on.

So I guess my question is has anyone dealt with the fact that Euler angles don't always come out how you expect in the past and found a good way to work around it?

Also, I'm confused as to how the rotation I create in 2 steps (y=90, then x=-105) which I would expect to be (-105, 90, 0), resolves to what unity gives me, which is (-75, -90, 0). With the blank box that I'm using, these rotations appear equivalent, but they're not really. In the first case, the original down-facing side of the box faces up and to the right. In the second case, it's facing down and to the left. The more I think about this problem, the more confused I get... :-/

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Nov 06, 2010 at 04:44 PM

The best way is to track rotations yourself, like the standard MouseLook script does, for example. If that's not possible, such as trying to read back rotations from an object that's subject to physics and not under direct script control, then that's a different matter and I don't really know a good solution.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image camjackson89 · Nov 07, 2010 at 04:43 AM 0
Share

Nah it's all scripted, not using physics control on the plane, so I think that might be a good solution. The other idea I came up with is just to infer the angles from the transform's 3 unit vectors, but it's not as neat. Cheers.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to Constrain Quaternion Rotations Over Time? 1 Answer

Limit rotation angle on Z axis while slerp 1 Answer

How to Rotate a CUBE by 90 Degrees when a key is pressed 1 Answer

"Object reference not set to an instance of an Object" 0 Answers

EulerAngles value as floating point 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges