- Home /
Max scale in unity3d
Hello. What is the max scale for objects in unity3d + scale-factor?
Can i make planet size = 60000 and ship size:0.001?
If max scale = 100000, then why? Float has value limit from -3.402823e38 to 3.402823e38.
Answer by GameVortex · Jan 06, 2015 at 02:55 PM
You can set all values of a transform to as high as floats values can go. Physics simulation and everything will run as normal. The problem you run into is the Imprecision of float values. Which gets really noticeable with large values.
A simple test/example I use to show people to demonstrate this is:
1: Create a new scene
2: Create a Sphere (with collider)
3: Put the sphere at x position 100 000.
4: Focus the sceneview on the sphere and try to rotate the camera around it. Already now you can see slight jittering of the sphere.
5: Set the x,y,z scale of the sphere to be 0.01.
6: Focus the sceneview on the sphere and try to rotate the camera around it. You will see that the collider and sphere will jump all over the place.
This is the result of the imprecision of floating numbers. It is not that the sphere actually moves around (its transform position is static), but its position is too imprecise to actually draw correctly every update or the camera movement is too imprecise or similar.
So this is something you need to take into consideration when working with large numbers.
Space simulators with accurate scaling (for example Kerbal Space Program) solves this issue by never actually moving the camera away from the center of the scene, but rather moving all objects around instead. So when focusing on a planet far at the edge of the solar system, the entire solar system is moved to position the planet correctly in the center (0, 0, 0) of the scene.
And what is the max/$$anonymous$$ ratio beetwin size and position?
There is no ratio, or max and $$anonymous$$ value (except max and $$anonymous$$ float values). Just keep in $$anonymous$$d that the larger the values the more imprecision you get.
Answer by tanoshimi · Jan 06, 2015 at 02:06 PM
Not sure why you couldn't have done this yourself, but never mind...
Just thought I would add this comment, if you're really in to computer program$$anonymous$$g / scripting and computer science, and math is no problem for you (its really all basic algebra and mathematics) then a great book I would recommend any budding programmer is Write Great Code by: Randal Hyde. It may look intimidating at first but its actually an easy read and quite fascinating my opinion! Its chock full of useful tips, and facts about computer program$$anonymous$$g. Chapter 4 of Volume 1 (there are four of these books) will give you great insight in to what floating point values are, how they work, and why they are so imprecise at large vs small scales.