- Home /
max dimensions of Unity world space (bounds for the x,y,z values of vector3)?
From an object at world position vector3(0,0,0) what is the largest (+ and -) values I can use for x, y, z to place other objects?
I read that x, y, z, are floats. But its not clear what is the furthest away I can place objects from an object at 0,0.0 in world space.
Answer by Eno-Khaon · Jul 05, 2016 at 05:12 AM
For a single-precision floating point number, the absolute maximum possible value is approximately 3.402823 × 1038.
That doesn't mean the value will be of use, however.
Floating point numbers basically work like this:
You start with (sort of) an integer, such as 5492637. Then, you add a decimal point to it. The number becomes, say, 549.2637. This can also be represented using scientific notation as 5.492637e2.
Eventually, you won't see any change in the length of your initial number, but the exponent can continue to change. This is where floating point inaccuracy becomes more and more noticeable.
The smaller the value is, the more accuracy you'll have. The greater the value is, the less accuracy you'll have.
For example, let's use the same number and make it tiny and huge. 5.492637e-4 vs. 5.492637e10. Alternately, 0.0005492637 vs. 54926370000.
If both those base numbers are increased by 1, you'll see a change of either 0.0000000001 or 10000.
Now, how does this tie in to your original question?
Well, if your objects are placed far enough away from the center point of (0, 0, 0), you will have much less granularity on their movement. If your objects can only move 10000 units at a time due to being far away from the center, it simply wouldn't be practical for gameplay. Incidently, this issue plagued Kerbal Space Program in its early days, until they changed the game to move the universe around the player and not the other way around.
Finally, this is also why Unity offers a word of advice as well: It is not recommended to go any further than 100000 units away from the center (and the editor gives warnings to that effect, in fact), and it's probably wiser still to remain within 10000 when possible, to play it safe.
Answer by rsud · Jul 06, 2016 at 06:56 PM
Thanks!
I also learned to form the world around the player who is always at 0,0,0.
Since its a space game, and space is huge ( I''ve heard :-) ) I'll store their true position in a seperate double. They will only be renderable if within 10,000 of the plater.