- Home /
Is there a limit to how large a position value can go?
Current game has trash scale, It is beyond difficult to fix with the current models, so it travels about 1000 values of x in a matter of like 2 seconds
it works really well so i'm not too worried, but I've read elsewhere that its possible to reach some "max float" and that this can happen with endless runners
Can anyone provide any insight into this?
Thanks!
Answer by tuinal · Jul 15, 2020 at 04:55 AM
A float is a long number with a decimal point, so if it holds a very large number, it loses decimal places.
What this means in a practical sense is objects with a very large transform position have a correspondingly lower accuracy, and will start clipping into each other and z-fighting.
I think Unity performs a translation from world to camera space before rendering to help avoid this, but that won't magically create the missing decimals.
I would try changing the import scale down on the models; it may be time-consuming but the other drawback of very large units is a lot of systems assume 1 unit = 1 metre, and you'll likely run into issues with physics & animation down the road which whilst fixable mean you end up writing scripts designed to work with crazy scales, and which thus aren't transferable/reusable. A lazy fix is to put your environment as a child of a single gameobject and set it's scale to the inverse (e.g. 0.001).
Yea, I ended up fixing all the physics (It actually made it nicer and arcadey feeling -- which is what I was going for)
Do you perhaps know how long until that would happen? I might consider just redoing the scales for everything and redoing the current physics if it means that much but if it would take A LONG time for the player to get to that point, I'm alright with it, the objects spawned that require "precision" or would matter if they clipped are spread apart by 10m (through script) so if i understood correctly, they wouldn't clip and therefore everything should be good?
Thanks for the response, this topics kinda funky for me and I'm trying to deter$$anonymous$$e if its truly worth it to switch everything!
Your answer
Follow this Question
Related Questions
Separating smoothDampTime into separate axis 0 Answers
What is the max float? -1 Answers
How to calculate distance to top of ground in Unity 2D 0 Answers
Use Another Float Value As Range Attribute's Max Value 1 Answer
C# round transform.position floats to .5 2 Answers