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 GameForger · Mar 03, 2013 at 10:19 AM · errortransforminspectorfloateulerangles

Transform rotation 180° becomes -5.008957e-06?

I wrote two simple scripts: The first is:

 using UnityEngine;
 using System.Collections;
 
 public class Cube : MonoBehaviour {
     public GameObject goSide;
     public Side sideToon;
     
     // Use this for initialization
     void Start () {
     goSide = new GameObject("NewSide");
         goSide.AddComponent<Side>();
         goSide.transform.parent=this.transform;
         goSide.transform.localEulerAngles=new Vector3(180.0f,90.0f,0.0f);
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 }
 

The second is this:

 using UnityEngine;
 using System.Collections;
 
 public class Side : MonoBehaviour {}
 

I created a cube, attached the cube Script. When playing the inspector shows X Rotation= -5.008957e-06 (???)

When using other numbers strange results appear. When using 90.0f everything is fine.

The rotation in Game seems correct. Some aftereffects occure. Whats going on?

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

2 Replies

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

Answer by GameForger · Mar 03, 2013 at 03:48 PM

How do I write that code then?

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 robertbu · Mar 03, 2013 at 04:01 PM 0
Share

There are lots of different ways of calculating and setting the angle. Typically if you are dealing with eulerAngles, you maintain your own Vector3, and you do your calculations on that...then you set the rotation. Think of eulerAngles as thing you can set but should be very cautions how you use the data you read from them.

avatar image
2

Answer by robertbu · Mar 03, 2013 at 10:31 AM

-5.008957e-06 can be rewritten as 0.000005009857 or in other words zero. If you look at your Y and Z rotation, they likely are not what you expect either. For many rotations, there are multiple different combinations of x,y and z values that are the same rotation. Unity has just picked a different combination from the one you expect (but the rotation is still the same). This can cause problems for code that reads the eulerAngles and expects particular values, but I don't see that issue in the code above.

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

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

9 People are following this question.

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

Related Questions

Floating-point errors while assigning transforms 1 Answer

transform.position.x brings up error 1 Answer

Bone Not Rotating? 1 Answer

BCE0023 error 2 Answers

How do I set an objects euler rotations to match the objects transform in C#? 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