- Home /
Questions about voxel terrain(loading/saving and optimizing performance)
Hi,
I am working on a cube world-type voxel game. I managed to generate chunks via PerlinNoise, but I got stuck when trying to save/load them using a text file. I looked all over the internet and through several games to see how they managed it, but I still don't understand it. This is my first game and I have not gotten much experience, but I now the basics of Unity.
Also, every time I try to play, I get intense lag. I have already multithreaded as much as I could, but it hasn't helped.
In my GenerateChunk method, I instantiate a square of voxels in a 16x16 square, then load in dirt and stone underneath that square. I had to use mesh colliders to be able to place blocks manually, but even changing them to box colliders(rendering player block placement impossible) does not increase performance much.
Please tell me which snippets of code I need to upload!
Any help would be appreciated!
-Qo2770
EDIT: Could someone tell me how I could hide blocks that are not visible (Adjacent to air or water)?
Hard to say without knowing exactly how you generate your terrain chunks and colliders. In any case, take a look at this gem of a thread if you haven't already:
After playing $$anonymous$$ecraft...
Also, saving to a text file is something I used to do for my voxel game as well. Don't do it. Even though I only saved 24x24x16 blocks, it was rather taxing. Ins$$anonymous$$d, serialize your data and write it to a file. You can use SerializeHelper , for example. I advise you to first get your terrain generation in order before diving into saving & loading data, since it's a whole new field full of pits and traps :)
Answer by Runalotski · Jul 22, 2015 at 11:57 PM
http://alexstv.com/index.php/category/voxel-tutorial
This has all the voxle stuff you could want to start with including saving and loading.