have tile map in photoshop 68 width 16 height pixels.
I go through the picture with this script
void GenerateLevel()
{
for (int i = 0; i < map.width; i++)
{
for (int j = 0; j < map.height; j++)
{
DrawTile(i, j);
}
}
}
void DrawTile(int w, int h)
{
Color pixelColor = map.GetPixel(w, h);
count++;
if (pixelColor.a == 0)
{
return;
}
foreach (var tile in tiles)
{
if (tile.color.Equals(pixelColor))
{
Vector2 pos = new Vector2(w, h);
Instantiate(tile.obj, pos, Quaternion.identity, transform);
}
}
}
and I get the following result, in this place where the red square is located, it moves and kills several blacks. I did not understand what to do, and decided to draw the picture through Gizmos, and what I saw
private void OnDrawGizmos()
{
Gizmos.color = Color.white;
for (int i = 0; i < map.width; i++)
{
for (int j = 0; j < map.height; j++)
{
Gizmos.color = map.GetPixel(i, j);
Vector2 pos = new Vector2(i, j);
Vector3 cube = Vector3.one;
Gizmos.DrawCube(pos, cube);
}
why is this happening, why and how to fix it? I would like to have a map with all the traps, or is this problem not resolved procedurally? Perhaps any other solution or advice will do.