Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by madmortigan · Nov 25, 2016 at 09:32 PM · rotationgameobjecttransform.rotation

After gameObject rotation is set, it changes to a different value

I am setting the rotation of a game object in some part of the code, as follows:

gameObject.transform.rotation = q1

where q1 is a quaternion with the new rotation I want for this game object. Immediately after the rotation is set to q1, the game object transform appears to be set correctly. I confirm this eg. via Debug.Log before I exit that function in my code. In the next Update call for this game object, I obtain the rotation and it's not what I set it to, but it's set to another value - say q2. The game object does not have a rigidbody attached to it. I have debugged my code and it does not set the rotation to q2. Is it likely the change to q2 is normal unity behaviour - and if so, how can I find out about where the object transform is set to q2.

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
0

Answer by ElijahShadbolt · Nov 25, 2016 at 10:36 PM

I don't know much about Quaternions, but maybe the Transform.rotation property does something to q1 when you set it, like clamp its angles? If you want the exact value of your quaternion to stay the same, maybe you could have a private Quaternion in your script, and set transform.rotation every update.

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 madmortigan · Nov 25, 2016 at 10:51 PM 1
Share

Thanks for your answer. If I Debug.Log the transform immediately after I set the rotation to q1, it appears to be set correctly. The change to the value q2 appears after that function has exited, Unity has taken control and I recover the game object later in the Update function. So it doesn't seem to be doing any clamping, at least not on the spot. On top of that, there seems to be no reason for any clamping or similar. Having the rotation as a property in my script defies the point of the transform in GameObject, don't you think?

avatar image hexagonius madmortigan · Nov 25, 2016 at 11:30 PM 1
Share

correct me if I'm wrong but since Quaternions don't exceed 180°, it might very well be that you read an adjusted version of your Quaternion.

https://docs.unity3d.com/$$anonymous$$anual/QuaternionAndEulerRotationsInUnity.html

avatar image ElijahShadbolt · Nov 26, 2016 at 09:04 AM 0
Share

Also, why do you need the Transform's rotation quaternion to exactly match what you set it to in the previous update? I can't think of a reason why it would be necessary, if both Quaternions do indeed represent the same rotation.

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

106 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 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 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 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 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

how to point the positive Y axis of an object to a direction 1 Answer

Rotating the player with mousePosition problem. 0 Answers

GameObjects 0 Answers

How do I properly add a light to a 3d model character? 1 Answer

After Rotating a Prefab, Transform.Position of children is inaccurate 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