Skip to content
Procedurally generated caves in 2D and 3D, using a cellular automata and marching squares/marching cubes
C# Other
  1. C# 99.4%
  2. Other 0.6%
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vs
.vscode
Assets
Library
Logs
Packages
ProjectSettings
obj/Debug
1.PNG
2.PNG
Assembly-CSharp-firstpass.csproj
Assembly-CSharp.csproj
MarchingCubesCaves.sln
Procedural-2D-3D-caves.sln
README.md

README.md

Procedural 2D and 3D caves

Youtube video available here: https://www.youtube.com/watch?v=3bV9xQNdMzo

This is a project where caves are procedurally generated in 2D and 3D. The generation is based on a cellular automata:

  • First, a random map is generated with empty spaces (0) and walls (1), and then smoothed depending on the amount of walls in a given zone.
  • Then, the final empty spaces will form rooms. These rooms are then linked to one another, in a manner where each room is accessible.

In 2D, a mesh and a collider are then created with a Marching Squares algorithm.

In 3D, the Marching Cubes algorithm is used. In this project, the faces are inverted so that the player explores the inside of the caves. The mesh is also separated in several pieces, in order not to reach Unity's mesh vertice limit.

Controls:

  • Right click in game to generate a new cave with the given editor parameters (warning, in 3D the delay can be long if the map is too large)
  • Use ZQSD and Space to move the yellow cube in 2D, or to move the first person controller in 3D

You can’t perform that action at this time.