- Home /
Tilemap having borders between tiles
I'm having that problem with Tilemap where the tiles have lines between them. They dissapear if I disable antialiasing, as mentioned by many people. The problem is, this is a 2.5D game so antialiasing is needed for the rest of the objects.
How can I fix this? Any advice is appreciated. Thanks.
Answer by seandolan · Jul 08, 2018 at 03:12 AM
There are a few things that can cause this. If you are using a texture to colour in the tiles, sometimes the texture is getting a little bit of the texture next to it in a tilemap. The quickest way to test this is to make all the textures the same so that even if they are "bleeding" then it will show just the same colour anyway. The other thing (which was the problem in my case) was that I was using separate tiles, where they meet each other, unity struggled to work out what to show. I just reduced my ground tile size from 1.0 by 1.0 to 0.999 by 0.999.
Try the texture thing first. Then try the size of your tiles. At 0.999 you won't see any gaps between the tiles, but unity will know that they don't overlap.
Going to test these now. Thanks. I'm pretty sure the first one is not the case since lines are transparent, and also disappear when disabling antialiasing. Even more sure considering that my texture atlas is just 4 tiles. But still, gonna try that first. The other option was something I actually wanted to do but didn't know how. So it's probably going to solve it.
I changed filter to Bilinear just so I could see more of the lines, and I noticed that they're actually the color from the adjacent tiles. So, I guess they're "bleeding", even tho the texture is alright, and it also looks alright in Sprite Editor. Of course, I switched the filter back to Point.
The thing that I don't get is: Why, assu$$anonymous$$g the textures are indeed bleeding, it stops happening when I disable Antialiasing.
I guess it is a problem related to AA ins$$anonymous$$d. Right? Thanks
It's probably more that the AA is hiding the impact. I had a similar issue when adding UVs to a mesh. This was my original code:
newUV.Add(new Vector2(tUnit * texture.x,tUnit * texture.y + tUnit));
newUV.Add(new Vector2(tUnit * texture.x + tUnit,tUnit * texture.y + tUnit));
newUV.Add(new Vector2(tUnit * texture.x + tUnit,tUnit * texture.y));
newUV.Add(new Vector2(tUnit * texture.x,tUnit * texture.y));
Then I changed it to get the texture but with an inner border of 0.01f. Like this:
newUV.Add(new Vector2(tUnit * texture.x + 0.01f,tUnit * texture.y + tUnit - 0.01f));
newUV.Add(new Vector2(tUnit * texture.x + tUnit - 0.01f,tUnit * texture.y + tUnit - 0.01f));
newUV.Add(new Vector2(tUnit * texture.x + tUnit - 0.01f,tUnit * texture.y + 0.01f));
newUV.Add(new Vector2(tUnit * texture.x + 0.01f,tUnit * texture.y + 0.01f));
but shouldn't unity pick the UVs correctly since I'm not coding it myself? I'm just using the Sprite Editor and it looks like this
Also, AA is not hiding the problem. Disabling it makes the game looks alright. With AA enabled, I get lines.