Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Hexagons Map

Options
  • 12-04-2013 2:51pm
    #1
    Registered Users Posts: 22


    I'm developing a game that will have players creating their own city, country etc. They will interact with the main game mechanics via many hexagon shapes covering the 3D map.

    I'm having a problem placing them in a pattern to cover the map.
    Image of Ireland that will be the map:

    249102.jpg

    Sorry for the size.

    How would i place them in a pattern like this:
    http://www.sciencekids.co.nz/images/pictures/math/hexagonpattern.jpg

    I can do it in 3d max but i would need to do it with Unity 3Ds C sharp in order to tell one from the other.
    249103.jpg


Comments

  • Registered Users Posts: 7,157 ✭✭✭srsly78


    Just treat it like a grid, but with one of the coordinates skewed.

    For a given hex(x,y) then you can calculate it's centerpoint f(x,y).

    This is the translation between "hex coordinates" and "world coordinates". For practical purposes you will need to be able to convert in both directions.

    Your hexes are addressed as a 2d grid like so (if you draw it on paper it's actually a trapezoid because of the skew, but can still be indexed in 2 dimensions):
    1,1 2,1, 3,1
    2,1 2,2 3,3
    3,1 2,3 3,3

    But to render the hexes you need to know their coordinates in world space. Just need to know your "zero point" - ie the position of hex 1,1, and the hexes radius.

    http://forums.epicgames.com/threads/728645-Useful-Functions-Hexagonal-Grid-Coordinates

    If you are still stuck then get pencil+paper+ruler out.


  • Registered Users Posts: 22 Ancel


    Thank for the advice.
    I also got good code from here, just have to get the logic of it.
    http://www.codeproject.com/Articles/14948/Hexagonal-grid-for-games-and-other-projects-Part-1


Advertisement