Infinite voxel world with cunks?

Hey,

the Idea with the Chunks is to sum up multiple Blocks into one 3D Array. So a Chunk is just, as you said, a 1616Z (don’t know how high a Chunk in Minecraft is) Array that holds the Data of what Block type it spawns.

So per Chunk, you have a 3D Array with Int Values, where an Int Value stands for the Block type (0 - Air, 1 - Dirt, etc).

Now you need a way to save these. Let’s say you always have 27 Chunks loaded. The one you are standing on, and the 26 around you. Imagine a Chunk is ONE big block, so you have, again, a 3D Array of Chunks that you can save.

Let’s remove the Chunks above and beneath us, so we only have plane of 9 Chunks. The one you are standing on and the 8 around you. If you move forward, you will eventually reach the Chunk in front of you, which is then the centered one. So the 3 Chunks that were behind you will be unloaded and the 3 in front of you will be loaded.

What does loading and unloading mean? Well, saving means you write the 3D Int Array into a SaveFile and loading means you read the SaveFile and iterate through the Array again.

And yes, this is done via Loops. It’s only 3 Loops iterating through the chunk Array.

Don’t use “SpawnActor” for your Blocks. You SHOULD NOT use Actors for your Blocks.

Actors are too heavy. I can’t see if you use Actors, but that’s not going to work. That would, indeed, explain why you have so long loading times. UE4, in Blueprints, has “InstancedStaticMeshs”. You will want to have one Component per Block type and spawn these based on the Int Value in the Array. They improve performance by a LOT.

Next thing you want to do to improve performance:

Only spawn visible Blocks!

Yes, why spawning blocks that have 9 blocks around them and you can’t see them anyway. When you spawn a block, check if you can actually see it (check if there is air around it or something that doesn’t block the view).

Minecraft goes even further: They only create the visible SIDES of the block. You could use the “Procedural Mesh Component” to actually only create the upper plane of a floor and not render anything beneath. That improves performance by A LOT. But, afaik, Procedural Meshs don’t have collision, so you need to at least have the chunks around you made out of Instanced Static Meshs.

Is Minecraft a good Project for Blueprints?

Well yes and no. John_Alcatraz made Minecraft in Blueprints with the Instanced Static Meshs around him and the Procedural Meshs for further away Chunks, but he eventually went to use C++.

Why? Because Minecraft is calculation heavy and Blueprints don’t offer many ways to achieve the whole Minecraft logic.

What Problems would i have with Instanced Static Meshs, since I shouldn’t spawn an Actor per Block?

Instanced Static Meshs are bound to one Material. They all share it, that’s what makes them so light-weighted.
To actually show the “Destruction” of a block, you would need to remove the InstanceStaticMesh instance and spawn a Dummy Actor at that place. If the Player stops hitting, heal the Actor back up, destroy it and spawn the Instance of the Instanced Static Mesh back.

You may see by now, that it’s a bit tricky to get Minecraft done in Blueprints. It can be done, but you need to have total knowledge about Blueprints and what they can do and how you can work around it.

Hope that helps getting started!

Cheers (: