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 /
This question was closed Jul 24, 2013 at 08:54 PM by robertbu for the following reason:

Duplicate Question

avatar image
0
Question by create3dgames · Jul 24, 2013 at 08:42 PM · rotation

Unity has a mind of its own on rotation

Is there some logical reason why when my script says: object.transform.rotation.x = 90;

then the object's rotation on the x axis will be all sorts of things like 180, but not 90?!

I'm going crazy trying to figure this out!

Comment
Add comment · Show 3
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 create3dgames · Jul 24, 2013 at 08:43 PM 0
Share

Also I tried transform.localRotation but that doesn't work either

avatar image robertbu · Jul 24, 2013 at 08:54 PM 0
Share

Of course Unity has a $$anonymous$$d of it's own. Unity wouldn't want to depend on our $$anonymous$$ds. ;-) Your issue is that transform.rotation is a Quaternion...a 4D, non-intuitive object, and unless you have a firm grounding in Quaternions, you shouldn't be addressing the individual components of (x,y,z,w). You can use Transform.eulerAngles to assign angles, but the reference warns to never assign the axes individually (i.e. don't do transform.eulerAngles.x = 90;). You need assign all three in a Vector3. Plus there are multiple eulerAngle representations for any given rotation, and Unity can change the representation on you. So you cannot depend on any specific value when reading the values. $$anonymous$$eep and manipulate your own Vector3 and treat eulerAngles as write-only.

Since this problem comes up so frequently and has been answered so many time, I'm going to put my answer as a comment and close this question as a dup. If you have trouble using eulerAngles, post a new question with your script.

avatar image AlucardJay · Jul 24, 2013 at 08:54 PM 0
Share

Euler Angles : http://docs.unity3d.com/Documentation/ScriptReference/Quaternion-eulerAngles.html

  • http://unitygems.com/quaternions-rotations-part-1-c/

1 Reply

  • Sort: 
avatar image
3
Best Answer

Answer by Eric5h5 · Jul 24, 2013 at 08:51 PM

Transform.rotation is a 4D quaternion. Rotation.x is not the X axis, and it doesn't use degrees, it uses normalized values from -1.0 to 1.0. Don't mess with quaternions unless you understand them. Look up Transform.eulerAngles instead, but pay attention to the part of the docs where they tell you not to set one axis by itself.

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Flip over an object (smooth transition) 3 Answers

accessing an array of rigidbodies at once? c# 2 Answers

Shoot an object and have it move based on rotation 1 Answer

Rotating a Prefab? 3 Answers

2D character rotation wrong direction when moving 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