Hex map graphical overlap issue in Unity2d
I've got a mostly functional procedurally generated hex map going in Unity2d. I'm getting down to the stages of refining things and trying to work out little kinks, and this one has me a bit stumped.
When I place my tiles, I iterate through a simple pair of for loops to call a tile placement function:
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
terrainGen.DrawTerrain(x,y,terrainType[x,y]);
}
}
Seems to mostly work, except that I'm having issues on specific parts of the rendered maps where some graphical elements that I want to overlap from one hex to the next are getting clipped (blue looks ok, red is clipped):
I'm pretty confused about it, even though I suspect it has something to do with the way I iterate through the tile placement, combined with the treatment of the odd and even rows, since I need to slightly alter their transform placement based on the row. Here is the coding I use to alter those row coordinates:
// coordinate system corrections for hex placement
if (y%2 != 0)
{
x = (120 * x) + 60;
y = (106 * y);
}
else if (y%2 == 0)
{
x = (120 * x);
y = (106 * y);
}
Anyone have a clue what would make it clip only on even-numbered rows or get clipped by the odd-numbered row, depending on how you look at it? The layering, sort order, etc. all seem to be the same (plus, they look fine on the next row down with the same tile). It also seems to only impact overlaps that should happen on the left/west side of the overlapping tile. Tiles in the same row that overlap on the right/east side seem to be fine.
EDIT: Credit to Kenney.nl for the graphic assets I'm using here (in slightly modified fashion, anyway).
Your answer
Follow this Question
Related Questions
No overload for method 'fireBullet' takes 0 arguments 1 Answer
Is it possible to prevent atlas calculation at each build ? 0 Answers
Change camera origin point to top left? 2 Answers
2d fixed path patrolling 0 Answers
Issue: deactivated animated sprites reappear and go crazy on animation state transition 0 Answers