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 Blink123123 · Oct 11, 2013 at 02:30 PM · c#rotationquaternionitween

Rotation 90.0001 and 1.001719 bugs!

 // flip according to direction
                 if(isHorizontal)
                     yAxis += 90;
                 else {
                     if (xAxis == 90)
                         xAxis = 0;    
                     else
                         xAxis = 90;
                 }
                 
                 // round the whole rotation
                 iTween.RotateTo(resource, new Vector3(Mathf.Floor(xAxis), Mathf.Floor(yAxis), 0), ANIMATION_TIME);

The code is working fine except for 1 problem, I am getting the rotation angle at 90.00000001 and 1.001719.

Now I don't think the 90.000001 degrees is affecting the outcome but the 1.001719 is affecting the whole object as it is not perfectly aligned anymore.

Is there a way to get the exact values?

The code will always return an integer value so is there a way I can tell it to make a rotation angle with integer values?

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 raimon.massanet · Oct 11, 2013 at 02:39 PM 0
Share

I am not familiar with iTween, but is there a callback that you can write when the tween is finished? If there was, you could overwrite the final rotation with the angle you want.

avatar image robertbu · Oct 11, 2013 at 03:41 PM 0
Share

The 1.001719 value is troubling and an indication of a bug somewhere. As @$$anonymous$$A mentions, the 90.000000001 is an expected result of using floating point numbers. As to @raimon.massanet's suggestion, iTween does have callbacks. If you decide to address your problems by explicitly setting eulerAngles, be sure to assign them all at once by assigning a Vector3. Don't address them individually.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by DaveA · Oct 11, 2013 at 02:33 PM

No, welcome to the world of floating point numbers. See http://docs.unity3d.com/Documentation/ScriptReference/Mathf.Epsilon.html

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 Blink123123 · Oct 11, 2013 at 02:35 PM 0
Share

can't I set it manually? like transform.rotation = quaternionangle or something like that? or transform.rotation.x = something

avatar image Blink123123 · Oct 11, 2013 at 02:36 PM 0
Share

I am rotating the object vertically and horizontally so its just 90 degrees each Can I somehow use the vector.up and so one ?

avatar image DaveA · Oct 11, 2013 at 02:55 PM 0
Share

You can set transform.eulerAngles or .localEulerAngles

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

19 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

Related Questions

Flip over an object (smooth transition) 3 Answers

How to always rotate clockwise 1 Answer

Keep objects current rotation, with Input Mouse X 0 Answers

Why is this rotation acting odd? 0 Answers

LookRotation is upside down? 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