Tile Factory

The tile factory is what is used to create world tiles. Primarily the world stacks within the world manager system directly communicates with this factory to order to construct tiles based its tile composition. More information on this can be found by following the link below.

Link to page about world manager development

Initially in terms of managing the tile models I would have 32 hexagon tiles that were created in 3DS Max that i would use in the tile factory in order to create tiles of varying heights. This was working fine for a long time, but I got tired of how uniform the world looked. I wanted a more natural look to environments, meaning hexagons that were not perfect. In order to achieve this I devised a procedural generation system for tile meshes that would make them jagged.

In order for me to achieve this I had to ensure that the tiles would continue to fit together perfectly. Meaning that if I ever offset a vertex of a hexagon, any neighbours that shared that vertex position had to apply the exact same offset to that vertex. Below is an image demonstrating how these vertices are offset. The circle represents the max offset distance, which is half the length of its sides. Extending past this circle would cause vertices to cross ,forcing faces on the mesh to turn inside out.

hextile offsetting

In order for this jagged effect to work I had to have multiple hexagon tile shapes that have been made jagged in different ways, but always fitting together. However I cannot afford to make every hexagon on the terrain unique, there has to be loop at some point to keep the system from being too resource heavy. I decided that there would be a 4 by 4 resolution of tiles before a loop, meaning that there would be 16 different hexagon tiles each made at 32 different heights. Meaning there would be 512 total meshes, however these meshes are so simple that it is not an issue. What I had to ensure now was that the loop of tiles didn’t cause cracks in the terrain. Below is an image demonstrating how I kept the loop perfect, by ensuring vertices on the edges with the same number got the same offset.


This resolution could be changed to higher resolutions, but 4 x 4 seemed a good amount. The end result was very pleasing. Below are some images showing the terrain at different strengths of offset to create tiles that get progressively more jagged.

The code for the tile factory system can be downloaded from the code listing page under the Hex World project files. These files are located within Assets >> Scripts >> Factory.