hey guys,
I’m currently working on a project where I need to create a hexagon grid and place the hex tiles on it.
No problem creating the grid, but placing the tiles on that grid seems to not work as it should.
It’s supposed to place the tiles from left to right and then go down and place the next row, starting at 0,0,0.
So the first tile (0,0) should be at 0,0,0 and the next tile would be at 1,0,0. and then 2,0,0, etc.
Instead, it places the first column(0) all the way on the right and the first tile (0,0) is placed last, or is at least in what should be the last position.
here is the code that makes the grid and places the tiles:
void Generate_Grid(int row, int column)
{
for (int y = 0; y < row; y++)
{
for (int x = 0; x < column; x++)
{
GameObject gameObject = Instantiate (Hexagon_Tile) as GameObject;
gameObject.name = "tile (" + x + "," + y + ")";
Hexagon_Tile.transform.position = new Vector3(x, z,y);
// i use x,z,y so that Z is up/down as normally used/done...
}
}
}
[I left out the code that actually makes the hex-grid]
I really don’t know why the tiles aren’t placed correctly, but they are ‘created’ in the proper order.
Also, sometimes “tile (0,0)” is placed at a wrong depth(y) all together…
If anybody could help me out here, that would be greatly appreciated!