- Edited
I'm working to create a dungeon roguelike currently using rectangular rooms on a randomly generated map. My map is generated as a 2D array of structs and it's working properly as far as I can tell. My question is, how can I assign the tiles at runtime into the game world?
This is what I'm currently trying:
TileMap mainMap = GetNode<TileMap>("Dungeon");
TileMap backMap = GetNode<TileMap>("BackMap"); // background tilemap, should cover all spots on the grid
for (int r = 0; r < numRows; r++) {
for (int c = 0; c < numCols; c++) {
backMap.SetCell(0, new Vector2I((r + 1)*1260, (c + 1)*720), 0);
if (gridMap[r,c].active) {
mainMap.SetCell(1, new Vector2I((r + 1)*1152,(c + 1)*648), 0);
}
}
}
}
The result of this code is currently three errors relating to getNode referencing issues. The previous set of errors I got was caused something along the lines of "These cells are already occupied", I fixed this by moving the world generation to its own scene and making that scene a child of the main scene.