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 jaxx0rr · Jun 24, 2014 at 01:53 PM · rotationobjectdegrees

Get object rotation for x axis in degrees (360)

there are several questions like this but none has the correct answer. I found:

 transform.localEulerAngles.x
 transform.eulerAngles.x

but they will just return the flipped value at 90 degrees or something..

what is the correct answer ?

a function would be useful, with input (axis:String, rotation:Vector3) and output 360 degree angle..

so basically heres the input and output needed (I observed the values by just dragging the x rotation gizmo on a brand new gameobject):

 getRealRotation("x", Vector3(60,0,0)) => 60
 getRealRotation("x", Vector3(70,0,0)) => 70
 getRealRotation("x", Vector3(80,0,0)) => 80
 getRealRotation("x", Vector3(90,0,0)) => 90
 getRealRotation("x", Vector3(80,-180,-180)) => 100
 getRealRotation("x", Vector3(70,-180,-180)) => 110










Comment
Add comment · Show 1
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 pickle chips · Jun 24, 2014 at 02:17 PM 0
Share

I dont understand whats wrong with using transform.eulerAngles. thats exactly what that is for.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by robertbu · Jun 24, 2014 at 03:00 PM

Transform.eulerAngles is derived from the Transform.rotation, a Quaternion. It is not stored independently. There are multiple euler angle representations for any given physical rotation, and the representation does not remain constant throughout all rotations. Assuming you are doing the rotation through manipulating the Transform, then the usual solutions is to maintain your own Vector3 and treat eulerAngles as write-only. That is, you execute whatever rotation code to the Vector3 first, then you assign that Vector3 to eulerAngles. That way your Vector3 will always be in a format that you control.

In situations where this cannot be done (like when using a Rigidbody and forces), you need to create a point of reference and calculate the angle yourself. This question creates a HUD display for a plane and calculates the pitch, roll, and skew.

http://answers.unity3d.com/questions/696271/how-create-modern-aircrafts-hud.html

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 jaxx0rr · Jun 24, 2014 at 03:17 PM 0
Share

what if I only want to rotate the thing in 1 dimension (x-axis).. its a sun/moon object with 2 lights in it.. and I need the rotation to rotate a 2d texture.. meanwhile (I posted this question 2 days ago but on that account it didnt get accepted) I used a workaround by using a int to increase time per frame.. it works but.. its ugly code There has to be a way to calculate the value with a function, i'm sure many people would use it.. (according to the many questions that I found about it)

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

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Snap the rotation 0 Answers

How can I rotate an object with certain degrees? 2 Answers

Limit Object Angle 2 Answers

how can i get Y rotation of Transform in degree ?? 1 Answer

rotate object with degrees 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