• 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
1
Question by anovan · Apr 16, 2012 at 03:48 PM · transformrotate

Transform.Rotate in X-axis

I faced up with problem of strange behaviour on transform.Rotate method in X-axis rotation.

JScript code is:

 function Update () {
     transform.Rotate(30 * Time.deltaTime, 0, 0);
 }

Strange behaviour: it makes object incremently rotates to 90 degrees in X-axis, then instantly rotates object in Y and Z axis in 180 degrees, then makes object decremently rotates to 270 degrees, then instantly rotates object in Y and Z axis back to 0 degrees and repeat from begining. Why?

In case of rotating in other axis:

 function Update () {
      transform.Rotate(0, 30 * Time.deltaTime, 0);
 }

or:

 function Update () {
      transform.Rotate(0, 0, 30 * Time.deltaTime);
 }

it works perfect - always incremently rotates object in appropriate axis and does not affect other axises.

Comment
Add comment · Show 2
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 kolban · Apr 16, 2012 at 04:14 PM 0
Share

If you apply this script to other objects, do they rotate correctly around the X Axis? If yes, then there is some property of the object that is causing your issues. What are the components of the target object? Look for constraints.

avatar image anovan · Apr 16, 2012 at 04:43 PM 0
Share

Nope, they rotate also incorrect. There are no other components(except standart Transform and $$anonymous$$esh Filter\\Renderer). I just created new project, added Cube object and applied this script to it. In case of X-axis rotate - same problem extists.

1 Reply

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

Answer by Eric5h5 · Apr 16, 2012 at 04:50 PM

It's because of converting quaternions (which is what's actually used internally for rotations) to euler angles for display. The results are not wrong; (90, 0, 0) is the same as (90, 180, 180). There's more than one way to correctly display the euler angles rotation.

Comment
Add comment · Show 3 · 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 anovan · Apr 16, 2012 at 06:24 PM 0
Share

Eric5h5, sorry that not in comment to your answer, but here I can add attachments.

here is (90, 0, 0) : 90a

and (90, 180, 180) : 90b

in YZ-plane projection for my object. They are not the same in my case.

90a.png (1.1 kB)
90b.png (1.1 kB)
avatar image Eric5h5 · Apr 16, 2012 at 06:29 PM 0
Share

You don't need to write answers to use images. I don't really understand what you're doing, but if you take a cube and set it to (90, 0, 0), it has exactly the same orientation that it does at (90, 180, 180).

avatar image anovan · Apr 17, 2012 at 11:31 AM 0
Share

You are right, (90, 0, 0) is the same as (90, 180, 180). It's time to me to re-read topics about quaternions.. Thank you very much!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Model rotation and hierarchy of game objects - not rotating! 1 Answer

Lock rotation axis? 4 Answers

LookAt Problem 1 Answer

Object rotation 2 Answers

transform.localScale unexpected behavior after Rotate() 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