Hi Guys
Wondering if anyone can help, been starting to try to make an isometric game. Got my tilemap setup followed the instructions. I’ve been try to generate a map over the top of the tilemap but every time it seems to be offset. Anyone got any ideas what I’m missing?
private void Start()
{
OnGridCellCreated += CreatePrefabOverlay;
CreateGrid();
}
private void CreatePrefabOverlay(Vector3Int position)
{
var cellPosition = _tilemap.GetCellCenterWorld(position);
var tile = Instantiate(overlayTile, transform);
tile.transform.position = new Vector3(cellPosition.x, cellPosition.y, cellPosition.z);
}
private void CreateGrid()
{
BoundsInt cellBound = _tilemap.cellBounds;
gridMap = new Dictionary<Vector2Int, GridCell>();
for (int z = cellBound.max.z; z > cellBound.min.z; z--)
{
for (int y = cellBound.min.y; y < cellBound.max.y; y++)
{
for (int x = cellBound.min.x; x < cellBound.max.x; x++)
{
var tileLocation = new Vector3Int(x, y, z);
var tileKey = new Vector2Int(x, y);
if (!_tilemap.HasTile(tileLocation)) continue;
var cell = new GridCell(x, y, z);
if (gridMap.ContainsKey(tileKey)) continue;
gridMap.Add(tileKey, cell);
OnGridCellCreated?.Invoke(tileLocation);
}
}
}
}