Sorry to survive and this topic, but for researching people about voxels:
- DO NOT instantiate actor for each voxel! No modern PC and NO Pc in next 20 years will be able to handle this.
- You must divide your world into zones, called chunks, and store voxel data for each chunk. How you serialize it is then up to you. In your generic case, 40x40x5 is small and really does not ned chunking.
- You must then generate an isosurface. There are a lot of algorithms, and each algorithm expects different input data.
For example, to make minecraft like world, you iterate each voxel, check neighbours and add a quad to the mesh only on places where a solid voxel borders air. You end up with optimized mesh. But you can even optimize it more, this is a geometry task.
You can also generate smooth isosurface. Algorithms are called Marching Cubes and Dual contouring.
And of course you need to be a real programmer that can take this challenge.