Unity Voxel Terrain Generator by michalczemierowski - 4


3D game with procedural world made of cubes, basic inventory system. (world generation/mesh creation/physx baking is multithreaded)

Unity 2020.2.1f1GNU General Public License v3.0Updated 20 days agoCreated on May 12th, 2020
Go to source

Voxel Terrain Generator

Unity Version: 2020.1.6f1


  • Procedurally generated terrain
  • Daylight cycle
  • Terrain modification
  • Multithreading
  • Saving/Loading terrain
  • Items, tools, weapons
  • Menu, async scene loading
  • Toolbar system
  • Living entities (early stage of development)


Screenshot 0 Screenshot 0 Screenshot 0

Code examples

Easy to configure event listeners

IBlockUpdateListener - called when neighbour block is placed/removed

public class OnGrassBlockUpdate : MonoBehaviour, IBlockUpdateListener
    public BlockType GetBlockType()
	    // Block type you want to listen for updates
        return BlockType.GRASS_BLOCK;

    public void OnBlockUpdate(BlockEventData data, Dictionary<BlockFace, BlockEventData> neighbours, params int[] args)
        // if above block is solid block
        if (WorldData.GetBlockState(neighbours[BlockFace.TOP].type) == BlockState.SOLID)
            // replace current block with dirt in next update
            data.chunk.AddBlockToBuildList(data.position, BlockType.DIRT);

IBlockArrayDestroyListener - called when block is removed

public class OnAnyDestroy : MonoBehaviour, IBlockArrayDestroyListener
    public BlockType[] GetBlockTypes()
        // register this event listener to all blocks
        return Utils.GetAllBlockTypes();

    public void OnBlockDestroy(BlockEventData data, params int[] args)
        BlockType type = data.blockType == BlockType.GRASS_BLOCK ? BlockType.DIRT : data.blockType;
        // instantiate particle at block position
        ParticleManager.InstantiateBlockDestroyParticle(ParticleType.BLOCK_DESTROY_PARTICLE, data.WorldPosition, type);
Show all projects by michalczemierowski