- Home /
tilemap problem with colour? explain why
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.
Answer by shyxiaolong · Apr 08, 2021 at 02:04 PM
figured it out. I set High Quality in the configuration mode of the card itself
but I added white with the 2nd layer in photoshop file. first lyer main blocks second empty empty with whit phone and basic transparent, and it seems to behave correctly, but most likely in the long run it will break again
Your answer
![](https://koobas.hobune.stream/wayback/20220613031954im_/https://answers.unity.com/themes/thub/images/avi.jpg)