Hi everyone!
I’m working on a project with an isometric Tilemap in Unity, and I’m encountering an issue with tile overlapping. I’m using a sprite pack that includes different designs for terrain tiles, such as grass, sand, and rivers. My goal is to fill the map with a default ground tile (e.g., grass) and then replace specific positions with other tiles (e.g., rivers or sand). However, the specific tiles are overlapping the default tiles, leaving parts of the default tiles visible, which shouldn’t happen.
What I’m Trying to Achieve:
- Fill the map with a default tile (
ground default
). - Replace specific positions with custom tiles (e.g., rivers or sand).
- Ensure the specific tiles fully cover the default tile.
Current Code:
Here is the code I’m using to create the tiles:
private static void createGround(string groundDefault, List<TileMapHelper.TileData> groundTiles)
{
SpritesManager.Instance.spritesDictionary.TryGetValue(groundDefault, out Sprite spriteDefault);
Tile groundDefaultTile = TileMapHelper.CreateTile(spriteDefault);
Dictionary<(int x, int y), string> groundTileMap = new Dictionary<(int x, int y), string>();
foreach (var groundTile in groundTiles)
{
groundTileMap[(groundTile.x, groundTile.y)] = groundTile.spriteName;
}
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Tile groundTile;
if (groundTileMap.TryGetValue((x, y), out string spriteName))
{
SpritesManager.Instance.spritesDictionary.TryGetValue(spriteName, out Sprite sprite);
groundTile = TileMapHelper.CreateTile(sprite);
}
else
{
groundTile = groundDefaultTile;
}
Instance.ground.SetTile(new Vector3Int(x, y, 0), groundTile);
}
}
}
The Problem:
Specific tiles (e.g., rivers or sand) are being rendered correctly in their positions, but the default tile (ground default) is still partially visible underneath, causing unwanted overlapping. This creates visual artifacts, as shown in the screenshot below:
How can I ensure that the specific tiles completely overwrite the default tile without causing visual artifacts in the isometric Tilemap? Am I missing a configuration or setting? Is there a different approach you recommend?
Thanks in advance for any help!