I am developing a voxel game (i.e. Minecraft, Cube World, InifiniMiner, etc.) in the Unity3D game engine using C# as my programming language.
One chunk is 16x16x16 blocks big. My code loads one chunk from file in ~12ms and generates its mesh in ~3ms. I can live with that, that is fast enough for the current state of the game.
My question is: How can I create a loading list the most efficient way? The player moves all the time, he is in motion. The world loads chunks in the direction the player moves. There may also be high buildings, so a few chunks on top of each other. When the building is "in sight" (a certain distance reached), it should be loaded completely. Am I better off having 16x256x16 sized chunks like in Minecraft?
This is a quite complicated topic and I need to be pushed into the right direction, because there are a million ways of dealing with this, but I am trying to find a compromise between not too complex to implement and very fast. If your approach is very complex, do not hesitate leaving an answer. I have little to no clue how to approach this problem.
What I tried in the past: Sort the chunk list based on distance to the player. So the nearest chunks are loaded first, and the most far away ones last. This led to slow world loading for some reason as the chunks below and above the player were loaded first, too, but it is more important to load the chunks that are on the same height as the player, as he needs something to walk on and not fall off the world. The player is not slow, he has a moderate to high movement speed.
I should note that I store the chunks in a C# Dictionary. The key is the ChunkPosition (x,y,z in chunks, so the first chunk is 0,0,0 and his right neighbor is 1,0,0 etc.) and the value is the Chunk class, which holds all the chunk data, its blocks and so on.
If you need more information, please ask in the comments.
Thanks in advance!