Blocky terrain optimization

So i have an idea on how i could optimize a blocky terrain like in minecraft, but i have o idea how to implement this in code so that it would work the right way. So my idea is when the world is generated each block would check if there’s a block on top of it, on it’s sides and bellow it. If it is surrounded by blocks the mesh renderer and collieder would turn off and if there aren’t blocks near it the block will stay visible. My questions are:

  • Will this increase the performance of a minecraft like game?
  • How would i create this in code? Would i have to use a raycast and see if it collides with other blocks?
  • How does minecraft hide it’s blocks?

You’re thinking about Minecraft in the wrong way. Minecraft doesn’t have a separate game object for each block. Regardless of if they would all be rendered or not, having a separate game object for each block would be ridiculously inefficient. Instead, each chunk is made up of a 3 dimensional array of data values that represent blocks. When a chunk is rendered, it checks each data values in the bock array, and makes a mesh out by checking each block’s face to see if there it is solid and if the player could possibly see it (i.e if it is bordering a none-solid block like air), and if so, will render a mesh for whatever face of the block that could be seen. For a much more in depth understanding, I recommend looking here.