Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity 3D & Playmaker - An experiment in generation. Can be used for level generation.

Feb 21, 2021
About this tutorial

In this Unity and Playmaker I am experimenting with Generation. Something I haven't tried before but the idea can be used for level generation, automated level design, and randomization. Absolutely NOCODE. Also check out How to Make a Bounce Game Series https://bit.ly/39HIYBU. To download these p

Written Guide

This experiment builds a generative landscape in Unity with Playmaker — no code, just FSM logic. A spawner walks a 5 x 5 grid like a typewriter, and at every cell it assembles a random tile from three arrays: a ground base, a tree trunk, and a tree top. The same pattern scales to any kind of procedural level assembly.

Step 1 — Set up the scene and arrays

In a new URP project, create an empty named Landscape with a child empty named Land Spawner, both at the origin (a temporary 0.5-unit cube marks the spawner visually). The FSM lives on Landscape and holds two float variables, position x and position z, plus three Game Object arrays: bases, tree bases, and tree tops — each loaded with three low-poly FBX models built in Asset Forge. The opening state uses Set Float Value to zero both positions, then Set Position to place the spawner from those variables.

Step 2 — Assemble one tile

Three nearly identical states run in sequence — create ground, create tree base, create tree top. Each does an Array Get Random into a variable (chosen base, chosen tree base, chosen tree top), then Create Object using that variable, spawned at the Land Spawner and parented to Landscape. A clever variety trick: to make tree tops optional, grow the tree tops array and leave slots empty — three tops plus three empty slots gives a 50 percent chance of a bare trunk; one empty slot in four gives a 25 percent chance.

Step 3 — March the spawner across the row

After each tile, a Float Compare checks position x against 5: less than 5 continues, equal or greater stops the row. The continue path does a Float Add of 1 to position x, then — and this was the bug that caused an infinite-loop crash in the video — flows into a separate Set Position state rather than looping back to the start, because the start state resets both floats to zero and the spawner would stack every tile at the origin forever. Loop the new-position state back to create ground, not to the beginning.

Step 4 — Drop to the next row

When x hits 5, a second Float Compare checks position z against 5. If z is still under 5, add 1 to position z and use Set Float Value to reset position x to 0 — the typewriter carriage-return — then loop back through the row logic. When z also reaches 5, transition to an empty stop state and the 5 x 5 grid is complete. Color-coding states in the Playmaker graph (blue for spawner moves, yellow for bases, orange for tops) makes this branching much easier to follow. A 0.5-second Wait state inserted after each tile lets you watch the world build piece by piece instead of appearing instantly.

Step 5 — Randomize for natural variety

As a finishing touch, a Random Float between 0.6 and 1 is stored and fed into Set Scale on all three axes of the chosen tree top, so no two trees are quite the same height. The same idea extends naturally to random rotation, color, and bigger tile libraries — which is what makes this little experiment a real foundation for procedural level generation.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →