
A Hex Grid Strategy Tech Demo
Engine: Unity
Project Type: Personal
This project is a framework of the core systems needed in 4X strategy games, built in Unity. The focus was on creating connected gameplay mechanics on a procedurally generated hexagon grid based game. It integrates turn based logic, unit crafting, pathfinding and more.
Key Features:
-
Procedural Map Generation using Perlin noise, Voronoi noise and Poisson disc sampling
-
Fog of War
-
A* pathfinding for unit movement
-
Crafting system using scriptable objects
-
City and district placement utilising scriptable objects
-
A playable WebGL demo
​

Procedural Generation

Unit Pathfinding

Unit Crafting
Technical Breakdown
Hexagon Grid
Due to the grid being made up of hexagons and not squares, there are a few different issues and a few different ways that a hexagon grid can be made. This project makes use of offset coordinates, meaning that it's generated in a similar way to a normal square based grid, just offset by the length of one of the hexagon sides to make the hexagons fit nicely together.


To find the distance between two tiles (which is needed for unit pathfinding, attacks etc), it's easier to make use of cube coordinates. This is because the offset direction changes depending on weather the player is on an odd or even tile. For this reason, I have made a function to convert offset coordinates to cube coordinates. This makes it a lot easier to calculate distance between tiles as the function no longer needs to consider if the player is on an odd or even tile.
Procedural Generation
Poisson Disc Sampling
Poisson disc sampling is used to find spawn points for the starting units. These points are also used to generate the biomes from, so these points are chosen before any map generation has occurred. This works by splitting the map into quarters and picking a random point in each quarter, while making sure no point is too close to any other point. This creates roughly even sized biomes most of the time.
Voronoi Noise
Voronoi noise is used to generate the biomes. This is done by finding out which tile is closest to which spawn point. I have numbers that represent the different biomes, 0-3. These numbers represent a biome material in an array. When the tile is placed, the Voronoi function then decides its biome, and the respective material is attached to the tile game object.
The initial version did not split the map into quarters. This created a map where 1 biome usually dominated the entire map.
Perlin Noise


The hexagon grid uses 3 different height thresholds, ocean height, base level, and the upper level. I use Perlin noise to decide this. I use the Unity implementation of Perlin noise. I have 3 thresholds, one for each height. When the height is needed for the tile,




