Saving Minecraft like game

Hello so my question is how can i save a minecraft like game so that all block variables and positions, rotation are saved when i quit and loaded when i play again. thx
every block is a separate actor.


i won’t answer the “How to save answer”, but i MUST tell you something about the last sentence:

That’s a no go. With thousands of blocks you will run into performance issues pretty fast.
I recommend using either the InstanceStaticMesh Component or thinking about a way like Minecraft did it.

They are building the meshes by hand (letting the Engine render triangles based on given verts).
Only visible Block sides are drawn etc. I did a Minecraft game in Unity a few years ago.

Minecraft is already running poorly (though that’s mainly due to Java) and they are only rendering the visible sides
of each block. So if you place too blocks onto each other, the 2 sides that they meet on aren’t drawn.

I think Minecraft checks if the Block (for each side) is AIR or not. If it’s not AIR, then don’t draw the side.
Of course it’s not only doing this for AIR, but also for other things that don’t completely cover the side.

So if this, for example, is a chunk of blocks:

Then this is all that will be rendered. If you now remove a block, the block that sits beneath the one that got destroyed will have an AIR block
above it and its upper face will be drawn.

This saves LOTS of performance.

And remember that minecraft uses randomly generated worlds, with a seed.
In other words, all you need to save is the seed and the blocks the player has changed, (and blocks that have changed, such as water flow) since you can just regenerate the world.
The only problem is you need to generate the rest of the world each time which can be slow, so I guess experiment.

I would look into Voxels if I where you.

I understand the save game object and stuff like that so thx but a question how can i do that thing that you are talking about. I’m quite new to unreal but i also learn very quick. thx for yout reply.

Yes i know those but i dont want to use them :slight_smile:

how can i do the thing with not rendering not visible sides? i quite new to unreal but i learn fast.

If you don’t use voxels, I’m sorry but your game will be VERY slow. As eXi said, even using voxels (which should speed up game a hundred times faster) is slow. Imagine a 16 x 16 x 256 world. (A single chunk in minecraft) that is 6400 Actors! Not even static meshes! And that’s just a single chunk, when minecraft often has hundreds at once!

Use voxels, my friend. They are your bet! :smiley:

(Oh look! A voxel plugin!)

If you really don’t wanna do the voxel thing, what I guess you can do is have six planes arranged into a box. Then to build the world you would loop a bunch of arrays, and every time you place a block you check if a solid block is to the left of the box, and if so, hide the left plane, and so on. (I say solid cause if you had glass you would not hide it)

and when i have voxels is it possible to make like those hopper to chest interactions?
i will look at voxels. thx again

Oh and also are there any good tutorials on how to make voxels work

I would suggest you to do something else first in UE4 :stuck_out_tongue: Starting with something like this is a bit too much I think.

And another suggestion for once you start with your minecraft clone: Don’t start with a few blocks. Start with having hundreds of thousand of blocks. It’s all very easy to do if you only have a few hundred blocks. But it’s getting complicated once you have a bigger world (10010050 = 500,000). If you start with only a few blocks, you probably have to scrap all your code later and do it all differently.

Any suggestions with what should i start?

On something easier. Start out watching the Epic youtube tutorials and following along with some of those and you will learn a lot faster.

You can do a minecraft clone using Instanced Static Meshes with a few hundred thousand of them on screen without too many issues, but I still wouldn’t advise it, Voxels are definitely the way to go. But since there is no publicly available, free voxelization engine for Unreal then it’s most likely beyond your current skill level. So start small and research and wait a while for an easier to use Voxel engine to come out.

how can i code in that minecraft like this coment for i don’t know