I don’t know why, but everything in unity starts to collapse once I get too far away from my default location(the location where Unity ‘puts you’ in the beginning i guess it is 0,0,0).
So, here is the situation - I have an endless desert - terrain tiles which rearrange themselves accordingly to the player position. The player itself is the default First Person Character. If I get too far away - for an example 3km from my default position some of the objects start to flicker with black stripes, some of my scripts are stop working for no reason - I’ve made a system for picking up objects, very simple one, based on mouse enter event, but strangely sometimes it refuses to work when I’m too far away in the desert. I’ve made hundreds of test all my code is working flawlessly as long as I’m no more than 1 or 2 km away from the default location. Do you have any Idea what could be the problem? Please help.
You’re probably hitting an issue due to the limited precision of floating point numbers. Floating Origin is a common solution, where all objects in your game are periodically repositioned so the camera is close to 0.0.0.
Thank you for the fast reply Joe
I did little research about the floating point precision and it seems like a common hardware limitation, I guess making an infinite world is not a good idea. Turns out even Minecraft is not truly infinite and it hits the floating point issue at some moment when you’re too far away from the origin…
Changing this to doubles, which would largely resolve the issue, is currently the highest voted idea in the graphics category, and where all 10 of my votes have been sitting for a couple years.
Well I found another way around that I think is more simpler and I guess truly infinite, so here’s my solution:
We have 9 tiles for the whole terrain setup.
Center tile is the parent of all other adjacent tiles.
All tiles are seamless and the same.
With the ‘Start’ method we assign a V3 variable with the Center original position.
If the player enter inside, let’s say, the ‘North’ tile, The Center tile will occupy the location of the North tile, then parent all objects including the player to itself, then we reset the Center position to its default(original) position and finally we unparent all the objects.
This way all the objects will move around Unity’s point of origin and when we interact with them their coordinates won’t be so huge so we won’t hit the floating point limitation. Also it will leave the illusion to the player that he is traveling into an infinite desert while he’s actually walking like a hamster on one place.