World Generation
WorldSettings ScriptableObject
The WorldSettings asset defines all the core parameters for procedural
world generation.
Create a new asset via:
- Right-click in Project window →
Create → Pixit → Block World → World Settings
Fields may vary slightly depending on your version, but typical settings include:
Chunk Size
chunkSizeXchunkSizeYchunkSizeZ
These control the dimensions of a single chunk in blocks.
Example: 16 x 32 x 16.
World Size (in chunks)
worldSizeChunksXworldSizeChunksZ
Controls how many chunks are generated in the X and Z directions.
Example:
worldSizeChunksX = 4worldSizeChunksZ = 4
Total world in blocks will be:
- Width:
4 * chunkSizeX - Length:
4 * chunkSizeZ
Height & Mountains
minGroundHeightmaxGroundHeight-
Base terrain height range (Y) in blocks.
-
maxWorldHeight -
Safety cap for the vertical world size.
-
mountainThreshold -
Noise threshold above which extra height (mountains) are added.
-
mountainMaxExtraHeight -
Max extra height on top of the base ground height.
-
baseNoiseScale mountainNoiseScale- Perlin noise frequencies used for the base terrain and mountains.
Seed
seed- Integer used to seed the random and Perlin noise.
- Changing this value generates a different world layout while keeping the same overall rules.
Blocks & Ores
A typical setup:
- Regular blocks (grass, dirt, stone, etc) are defined as
BlockData. - Ore blocks (e.g. diamond) are also
BlockData, but have ore-related fields set: isOre = trueminY,maxYrarity(chance per eligible stone block)
The WorldGenerator will:
- Fill the chunk with stone (or a base block) below a certain height.
- Add dirt and grass layers near the surface.
- Optionally apply mountain extra height on top.
- Run an ore pass and replace some base blocks with ore blocks based on the ore rules.
WorldGenerator Component
Attach a WorldGenerator to an empty GameObject (e.g. WorldRoot),
then assign a WorldSettings asset in the inspector.
At runtime, the generator will:
- Loop over chunk coordinates:
(chunkX, chunkZ) - Instantiate
Chunkprefabs or build chunk objects as children. - For each chunk:
- Fill its internal block ID array based on height noise and layers.
- Call
BuildMesh()on theChunkto create the combined mesh and collider.
Performance Notes
- Larger chunk sizes reduce the number of GameObjects but increase mesh rebuild cost.
- More chunks increase draw calls and memory usage.
- For most “simple demo” use cases,
16x32x16chunks and a4x4world is a good starting point.
You are free to:
- Generate only a column of chunks around the player
- Add streaming / pooling
- Save and load chunk data from disk
These advanced topics are left to your specific project needs.