Hey guys. Please help me on this. I’m trying to make a large turn based game with square grid that has six neighbors instead of eight. I was wondering if there is a tutorial regards to this?
I don’t know of any tutorials, nor do I know of any shortcut. You’ve basically got a hex grid there, with rectangular graphics for each grid cell. That does make the math a bit easier, but you still just have to do the math. Each row will be offset by either nothing or one-half the cell width, depending whether it’s an even or odd row. Take that into account in all your placement & hit-testing routines, and you’ll be all set.
If that’s the case, to me its very inefficient since the game is very large, and each grid cell has different tile.
It doesn’t affect the efficiency of your code at all. (Well, a teensy little bit to do an extra comparison and addition or so, but this would be immeasurable compared to everything else going on.)
But if by ‘tile’ you mean a separate GameObject, then I agree, that is inefficient, regardless of whether you use a hexagonal or rectangular arrangement. You would solve that by using something like a dynamically created mesh, so that large sections of the map (or maybe the entire map) are just one object.
Alright, Thank you!
catlikecoding.com has a hex code tutorial just fyi
Before starting with catlikecoding, check out Amit’s Hexagonal Grids page. It has everything you need to know about hex grids from a theory viewpoint.
Then go do the catlike stuff.