I'm working on a game which loads smooth terrain around the player, and occasionally generates an island in the distance.
I load this terrain in chunks to avoid the Region3 size limit, reduce the amount of writing necessary, and to provide an easy to use interface to expand the game.
2. The Problem
The problem is, an island takes a considerable amount of time to generate. This delay means that any new requests to load voxels is delayed until that island finishes generating.
From what I've been able to inspect, I can not resolve this in my own code. The island can not be loaded at another point in time (the delay is unavoidable), and the data I supply to load the voxels has already been generated at this point.
As a Roblox developer, it is currently impossible to prioritize chunks closest to the player.
There are 3 possible solutions I can think of for this problem.
3.1. Provide a Loaded event
An event could be provided that fires when voxels finish loading.
With this solution, I would have to loop through a queue of voxel data (in the order I want them to load), and use the Loaded event to wait for the voxels to finish loading before continuing to the next chunk.
3.2. Provide a priority to WriteVoxels
The WriteVoxels method could be modified to take an integer (higher priorities first) that specifies it's priority. Internally, this priority could be used to determine what chunk of voxels to load first.
The new WriteVoxels signature could look like this (had to remove less-then, greater-then signs to post this forum):
void WriteVoxels (
array array array Material materials,
array array array float occupancy,
int priority = 1
By adding the new parameter last with a default of 1, this solution will be completely backwards compatible.
3.3. Prioritize closest chunks
Internally, collections of voxels closest to a player could be generated first.
4. Upsides and Downsides
I personally think solution 2 offers the most benefit, and the least downsides.
Solution 1 would require a different approach to loading voxels (requiring the largest amount of changes to existing games).
Solution 2 would require significantly less effort (on my end), although the priority of a chunk could not be modified once a request to write it is made.
Solution 3 would require no changes to the game, but might have unintended behavior with games that strategically target which voxels to write first.
5. Thank You
Thank you for reading this. Roblox is a community, so please reply if you have any of your own ideas, solutions, etc. I want this game I'm creating to have as much value to it's players as possible, your support helps to make that possible!