I’m creating a minecraft-type world, and I’m struggling to get chunks to load without freezing the game for 1-2 seconds. When my player moves, I need new chunks to render. I started off trying to load and render a full chunk column (16 chunks) at each tick, but the game freezes for like 10 seconds. So now I’ve tried load and render a single chunk each tick. The game still freezes for around a second each time a new chunk loads. What do you do to get around this problem?
The render code has nothing to do with it. It sounds like your loading code is way too slow. I would check and see if you can speed that up (maybe you need to use some run-length encoding in your storage format, for example). If not (or maybe even if so), you’ll just have to move the loading into a separate thread (which is a bit thorny since you can’t access Unity APIs off the main thread, but it can be done).