godot-procedural
Installation
SKILL.md
Procedural Generation (4.7)
Rules that save you later
- Seed everything. Use one
RandomNumberGeneratorper generator with an explicitseed(rng.seed = hash("my seed")for text seeds). Pass it down; never call globalrandf()inside generation. Show the seed in a debug overlay and save it with the game. - Data first, nodes last. Generate into arrays (
PackedInt32Array,Dictionary[Vector2i, int],PackedFloat32Array), validate, then write to TileMapLayer, GridMap or meshes in one pass. - Validate and retry. Flood-fill or path-check (
AStarGrid2D) that the start reaches the exit, enforce min/max room counts, then retry withseed + 1on failure. Cap the retries. - Threads build data; the main thread touches nodes. Use
WorkerThreadPool.add_task()for noise and mesh arrays, thencall_deferredto add nodes or set meshes. Seegodot-performance. - Rebake navigation after the level exists (
godot-navigation-ai).
Randomness API
RandomNumberGenerator:seed,state(save it to resume a sequence exactly),randi_range,randf_range,randfn(mean, deviation)(gaussian),rand_weighted(PackedFloat32Array)→ index (weighted tables).- Shuffle reproducibly: Fisher–Yates with your rng.
Array.shuffle()andpick_random()use the global generator. - Per-cell randomness without stored state: hash the coordinates, e.g.
hash(Vector3i(x, y, world_seed)), which is stable across runs and machines.