Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    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. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    3,415
  3. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    349
    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.