The repository contains an API to create, find and store data inside a hexagonal board using Unity Tile Maps and the math described by redblob & references.
A few reasons why I made the project:
- I wanted a generic API that could be easily be extended or integrated into a secondary project;
- I wanted set of generic classes that manage hexagons and are able to store any kind of data. What I mean by data: creatures, pieces, itens or whatever a main project needs;
- I wanted to use the native Unity TileMaps components;
You can find below images that illustrate the functionalities and an overview of the system's implementation.
Feel free to use this tool. Any kind of feedback or credit is well appreciated.
Playable demo here
Diagonals | Horizontal |
---|---|
Neighbours | Tile Orientation |
Add Objects | Remove Objects |
The interface menu to interact with the board data and test the operations.
I split the board implementation in three distinct parts:
- Board has a data shape that determines it's layout. Also holds a list of Positions that store the data elements on the board;
- BoardManipulation is resposible to implement the operations such as diagonals, neighbours or anything else that could come up in the future;
- Position is the class that holds the elements placed in the board; Currently each position is able to hold one single object, however it can be extended to an array;
There are two different Coordinates to manage, the Hex and Offset.
- Hex is used internally by the Manipulation to figure out the necessary points to include in each operation. Operations using this type of coordinate system have simpler algorithms.
- Offset is used by Unity TileMaps native component, in other words, we can't change it;
- OffsetCoordHelper is the class that manages the convertion from Hex -> Offset or Offset -> Hex;
- How to use the tool;
- How to define your own data;
- How to change tiles; ...