- Home /
how to implement hexagonal tiles?
I'm making a turn-based strategy game using hexagonal tiles, and I'm looking for an easy way to be able to move units and place tiles (without having to find the specific x and y values). Is there a way to do this?
Answer by ScroodgeM · Aug 10, 2012 at 08:41 PM
simply use field X*Y but skip all tiles that X+Y=even
now you get a something like checkmate tile placing. replace squares with hexagonals, a little scale in X axis and you got right hexagonal field 8)
declare a size of field (any number depends on gameplay), for example, X*Y=10*10
don't use in gameplay cells that are even or odd. use only odd or only even
in odd cells, draw tiles
write your gameplay 8)
may be not enough explained. tell if so.
I'm pretty new to Unity, so what do you mean by "field X*Y"? And what exactly do you mean by "checkmate tile placing?"
Thanks a lot! One last thing: how do I check to see if the X and Y for each position add to make an even number?
for (int x = 0;... { for(int y = 0;... { if ((x & 1) == (y & 1)) { ...place a tile here
what do you mean "x & 1" ? And if you are evaluating whether the x part is equal to the y part, then wouldn't that only create a tile on the main diagonal?
Answer by zyzyx · Aug 11, 2012 at 11:42 AM
You may want to check out this blogpost: Hexagon of Hexagons
Answer by deltadiamond · Aug 11, 2012 at 03:55 PM
Thank you! This was exactly what I was originally looking for. I now only have to figure out which method to use. Edit: I'm not too familiar with C#, so I don't know how to replicate that code.
Your answer
Follow this Question
Related Questions
How to fix this null reference exception? 2 Answers
Hexagonal grid with 120 degree angles 1 Answer
An arrow pointing from one hexTile to another hexTile 0 Answers
Cannot assign the tile png to the tile asset file 0 Answers
Shadows on floor edge 0 Answers