Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Hexagon Terrain

Discussion in 'Scripting' started by Unany, Sep 16, 2018.

  1. Unany

    Unany

    Joined:
    Aug 2, 2018
    Posts:
    1
    Hey,

    I've been working on a game for the past few months and have hit a bit of a snag code wise.

    While most games use 100's of hexagon tiles to make a game world, I want my hexagons (20 in total) to be terrains that are linking together and therefore don't want to be using a chunk system (or should I be?). Ive attached a quick diagram as I'm not great at explaining it.
    Unity question.png
    Currently, Im getting out an List of hexes with the following data ordered in ascending X, Y and then Z. I have the Cuboid cords of the hex, ID of the hex and rotation all saved within a List to be used.

    My question is: can anyone tell me which direction to head in for this? Ive read plenty of sites on hexagons but am still unsure of how to transfer this across to unity?
     
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,025
  3. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    502
    Programming in Unity is just regular programming. If you've found formulas for finding the center of hex (x,y), they'll work in Unity (except maybe you want to use x/z). Equations for an edge or corner will work the same. If the examples you see store them in a 2D array, do that in Unity.