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 quantumface · Dec 12, 2015 at 06:25 PM · transform.positionfloat

transform.position inconsistent numbers problem

Couldn't find answer anywhere. I have such script:

 if (transform.position.x == 0 {
     //aint workin
 }
 if (transform.position.x == desiredPosition.x) { //desired.x is 0.0 aswell
     //aint work in as wale
 }

And it doesn't work, even though it should. When I try to Debug.Log transform.position it gives out "(0.0, y, z)", which is normal. But whenever I do transform.position.x it gives out weird numbers like "2.328306E-10" even though it is at 0.0x.

I am using CharacterController.Move to move my character from point to point. Sometimes other locations bug like this aswell, but it is usually 0.0x. I know 100% that the transform is exactly at the desired location, and transform.position is there to back me up on this, but .x still prints out weird. Any way around this? Can I force move my transform to 0.0x somehow? Any help is appreciated, thanks in advance!

EDIT: I know that float numbers can weird out when you're doing calculations with them wrong, can this be the case here? The Vectors I use to .Move my charController are working and giving out proper 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 Owen-Reynolds · Dec 12, 2015 at 06:39 PM 0
Share

Look up all the parts. E-10 is scientific notation. You should also be able to look up how Vectors are rounded when you print them. "unity float precision" will probably get the many, many, many old Qs like yours, which have everything everyone could ever write about it.

avatar image quantumface Owen-Reynolds · Dec 12, 2015 at 06:45 PM 0
Share

Ok, thank you.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mhT3d · Dec 12, 2015 at 08:18 PM

Simply "2.328306E-10" is a very tiny number which equal 0.0000000002328, it seems like a kind of float numbers wired behaviors, and it is very common when working with UI where you do not get 0.0 but a number like that, so do not take care of it, Go Forward.

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

31 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

Related Questions

Floating Point Error? 1 Answer

C# function with multiple float arguments not working 1 Answer

Is there an int based class/struct like Vector2? 4 Answers

Unity Infinity Math Result 0 Answers

C# Min/Max Rotation based on Float? 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