Skip to content

About

A procedural city generator build in Unity using a tile-based constraint system. This work is meant to be used for future games or simulations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

42 Commits

Folders and files

Repository files navigation

(IN PROGRESS) Procedurally Generated Cities in Unity

Screenshot 2026-07-27 at 1 25 58 AM

About

This project is a procedural city generator build in Unity using a tile-based constraint system. I plan to use this work for future projects ex: games, videos, and simulations. Each tile defines edge types and the generator fills a grid by selecting tiles that match neighbor edge's. The system uses recursive backtracking to ensure a valid layout.

Features

  • Procedural city generation
  • Configurable generation settings

Built With

  • Unity
  • C#
  • Blender

Progress (Updating)

1) Tile Creation + Development

  • Tile-Edge constraints determine how it can connect to neighboring tiles. Tile rotations are automatically supported, increasing layout variety without requiring additional assets. (Current building + road assets Developed/Baked in Blender)
  • Screenshot 2026-07-26 at 11 20 27 PM
  • Screenshot 2026-07-26 at 11 17 38 PM
  • Screenshot 2026-07-26 at 11 18 52 PM
  • Generator uses recursive backtracking with weighted tile selection to build valid road networks, building blocks, and open spaces while respecting border and connectivity rules.
  • Screenshot 2026-07-19 at 10 00 30 PM

2) City Blocking

  • Changed generation system to use a district-based road layout system. Cretes varies urban block structures. First creates network of road bounderies that span between 6-8. The road positions are converted into a grid mask, which determines where roads must exist.
  • Screenshot 2026-07-26 at 11 14 00 PM
  • An issue in the beginning was that the roads would spawn within the blocks and generate these strange shapes, so I created a weighting system to make the probability of roads spawning 40x less likely than buildings. This doesn't completely rule out the possibility of having a road spawning in a strange formation, but makes it a little quirk that I want to be very rare, like a shiny pokemon.
  • Screenshot 2026-07-26 at 11 15 36 PM Screenshot 2026-07-26 at 11 16 15 PM

3) Code Optimization + Commenting

  • I recently learned about XML documentation and decided to use it for the first time in this project. Good practice to comment code. Deleted unused parameters and old/testing codeblocks.

4) Added Tile Variations

  • Added Building + Empty tile randomization. Each building tile type (1 door, 2 door, 3 door) have 2-3 variations of that building to bring more diversity to the city.
  • Screenshot 2026-07-27 at 1 19 42 AM
  • Three empty tile variations to choose from (empty, trees, lake)
  • Screenshot 2026-07-27 at 1 19 06 AM Screenshot 2026-07-27 at 1 18 52 AM

5) Next steps...

  • Adding more city customization. Ex: Creating a wall of buildings around the city, or making it surrounded by road.
  • Attempt to add features like traffic lights + more

Resources + Inspiration

About

A procedural city generator build in Unity using a tile-based constraint system. This work is meant to be used for future games or simulations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages