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 /
  • Help Room /
avatar image
-5
Question by Astrydax · Jul 05, 2021 at 05:50 AM · rotationscripting problemtransform.positionaccuracygarbage

Why is unity so bad at accuracy for something as simple as whole number coordinates.

All I want to do is make a simple block placement validator which is impossible when Unities location accuracy is almost as bad as their answer/forums community.

Additionally, here is some very odd behavior.

https://www.youtube.com/watch?v=sQdlcpmrN_U

alt text

alt text

  public static void SectionPlaced(GameObject mazeTile)
     {
         SectionValidation[] children;
         children = mazeTile.GetComponentsInChildren<SectionValidation>();
         foreach (SectionValidation sectionValidation in children)
         {
             
             if (instance.placedSections.Contains(sectionValidation.gameObject.transform.position))
             {
                 Debug.LogError("placed two sections in same spot");
             }
             else
             {
                 Vector3 a = sectionValidation.gameObject.transform.position;
 
                 Vector3 b = new Vector3(Mathf.Floor(a.x), 0, Mathf.Floor(a.z));
 
                 //this is the gameobject
                 sectionValidation.gameObject.transform.position = b;
                 instance.placedSections.Add(sectionValidation.gameObject.transform.position);
                 Debug.Log(sectionValidation.gameObject.transform.position);
             }
         }
         EventManager.TriggerEvent("OnPlaceTile");
     }
2.png (14.5 kB)
1.png (33.4 kB)
Comment
Add comment · Show 3
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 andrew-lukasik · Jul 05, 2021 at 06:14 AM 1
Share

You demonstrate no awareness for basics of computer science and that is ok. Everyone starts somewhere, everyone has his Achilles' heel; totally fine.


But please make sure your question is polite enough not to be mistaken for a rather unpleasant person. Thank you.


avatar image Astrydax andrew-lukasik · Jul 05, 2021 at 06:47 AM -2
Share

I could not care less. Polite questions do not get answered.

Post this 17 hours ago... and not a single response. https://answers.unity.com/questions/1846439/locations-being-stored-in-map-manager-are-inaccura.html

This got 2 response within the half hour.

That paradigm alone, is exactly why, and I say again, the unity answers/forums are garbage.

avatar image Hellium · Jul 05, 2021 at 12:28 PM 1
Share

If you want whole numbers, can't you use Vector3Int?

1 Reply

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

Answer by Eno-Khaon · Jul 05, 2021 at 06:18 AM

is almost as bad as their answer/forums community

First off, you're generally not liable to get assistance with your problem when you badmouth the community you're seeking help from.

Lucky for you, it happens to be an interesting (if still commonly seen) subject.


In short, floating point numbers aren't a replacement for integers. They're not really comparable to integers, in the sense that (computer) math is performed in a very different manner on them. Compounded on this, 32-bit float values will have even less precision allotted to them, that they will easily not land *exactly* on an integer value.

That is only partially related to your image examples, however.

Unity's implementation of Vectors ( Vector2/ 3/ 4), when calling ToString(), rounds the decimal places of their component floating point values to the nearest tenth (i.e. single decimal place).

For reference, Debug.Log() implicitly, automatically converts anything that isn't already into a string using any available ToString() function.
Comment
Add comment · Show 13 · 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 Astrydax · Jul 05, 2021 at 06:29 AM -1
Share

First off, the only question that I've ever had answered on here was answered 3 years after it was asked... so I could careless about the difference.

avatar image Astrydax Astrydax · Jul 05, 2021 at 06:31 AM -1
Share

you know what works? Saying what I said, and people respond almost immediately. Don't like that? Then create a community where that isn't the most efficient tactic available.

I've been using this community space for years with little to no interactions while being "polite"... Sorry to say mate, but "you're generally not liable to get assistance with your problem when you badmouth the community you're seeking help from." is bass awkwards. That is see$$anonymous$$gly the only to get any interaction, I don't like that meta either, but it works.

avatar image Astrydax · Jul 05, 2021 at 06:40 AM -1
Share

Case in point....

I posted this twice.... Guess which of the two actually got any intereactions?

Spoiler alert... it wasn't the one where I was being "polite"

https://answers.unity.com/questions/1846439/locations-being-stored-in-map-manager-are-inaccura.html

avatar image Astrydax · Jul 05, 2021 at 06:44 AM -1
Share

At any rate, I understand the limitations in converting primitives. Is the inspector also doing this?

Even in the game world the locations are off I don't see how string conversion would be affecting vectors there.

avatar image Eno-Khaon Astrydax · Jul 05, 2021 at 06:56 AM 1
Share

In some cases, the inspector adapts them for human readability, but in others, it doesn't.

In most cases, a value entered manually will be maintained as best as possible to be the same as what the user typed. However, programmatic values will only frequently/see$$anonymous$$gly-arbitrarily be displayed accurately.

That's really the key element here, though. In case the human-entered value and the script-generated value don't appear to be identical (and all the more if they actually aren't), that's part of why Mathf.Approximately() exists. If the value is different by a negligible amount, then it probably is functionally the same.

While the values may not be pleasing to the eye when they aren't displayed as whole numbers (or, rather, at the degree of accuracy you're hoping for), they're generally off by something like ~0.0000001 which, for all intents and purposes, may as well be zero.

avatar image Astrydax Eno-Khaon · Jul 05, 2021 at 12:11 PM 0
Share

its not though.

alt text

Even being off by 0.00000001 breaks the purpose of validation. And will allow the player to overlap two tiles.

These entries are also after calling RoundToInt and still losing accuracy.

capture.png (9.5 kB)
Show more comments

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

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

Rotating a cube in 3D ,Rotating a cube into specific coordinates with given input 0 Answers

Spine Look Rotation Wrong 0 Answers

Getting a 2D object to face the direction of its velocity relative to other objects in the level 0 Answers

AI targeting player in complete wrong direction 1 Answer

how to shoot on different direction while moving away 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