Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Hexagon Terrain

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

  1. Unany


    Aug 2, 2018

    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


    Feb 11, 2011
  3. Owen-Reynolds


    Feb 15, 2012
    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.