How to randomize and spawn a fixed number of grid blocks at level start

I’m working on a Minesweeper-like system with digging mechanics. The level is built from “dirt cubes” that the player can destroy to explore and create paths. If the character size is 1x, the cubes are 5x.

When a cube is destroyed, a random encounter is generated: enemies, items, clues, or empty results. I’m currently handling this using a Data Asset structure for randomization, and I’d like to scale the system to manage the whole grid of dirt cubes the same way.

My idea is to also use Data Assets for the grid definition, but I haven’t found a reliable method to ensure that, for example, when the level starts it generates exactly 30 cubes within a specific area.

Your Data Asset could hold the dimensions of the grid (width/length), so your 30 cube example could be a 3x10 grid or a 6x5, etc.
You’d spawn the cubes by running two nested loops that read the grid dimensions from the Data Asset, setting their positions based on the current iteration of each loop, multiplied by the cube’s size.

1 Like

Having try in full lenght, but this is the way!

Thanks!