Search Unity

Black lines on the edges of tiled sprites

Discussion in '2D' started by majlan, Feb 7, 2014.

Thread Status:
Not open for further replies.
  1. majlan

    majlan

    Joined:
    Dec 30, 2013
    Posts:
    12
    I tried to build a level according to this tutorial: http://imakeinternet.com/introduction-unity-2d-game-development/

    It provides a set of tiles to create platforms however when I run my game there are sometimes black lines between the tiles as I move my character around the level. I searched for the solution but I couldn't find anything helpful for 2D.
     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Make sure the settings in each texture are set to "Point" mode, and not "Bilinear" or "Trilinear".
     
    Boich and aceoverride like this.
  3. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    Also I found that reducing the pixels per unit a small fraction, say from 100 to 99.5 after you have placed the tiles, will stop gaps appearing between them.
     
  4. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    All that's going to do is make them overlap a tiny bit... So yeah, it could fix the issue in a sense, but it's better to solve the issue than to hack it.

    Make sure you're set to Point filtering mode, make sure yo'u using textures with power-of-2 dimensions, and make sure you're only placing them in position that are multiples of 0.02, so set your snap settings for example to 0.16 if you have a 100 pixels to unit ratio. Or set your pixel ration to something like 64 and just move it by single units or half units.
     
  5. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    Are you talking about THIS problem?

    His is blue, instead of black, because the default camera background is that blue. Let me guess? Yours is black. If so, it's the same problem.

    I listed all the possible solutions inside on THIS POST.
     
  6. mihakinova

    mihakinova

    Joined:
    Jan 6, 2015
    Posts:
    85
    I know this is an old thread, but I'll post my solution here in case it helps someone.

    My problem was a bit different, I had sprites with transparency in them (not tiles), and I was getting black lines on edges, especially when animating them. Since I load my sprites natively as png files using tiff files with an alpha channel was not an option.

    What I ended up doing, was opening my sprites in Photoshop, and under blending options I added a 2px wide white (or whatever color works for you) stroke, with transparency set to 5% and the position set to Outside. This worked very well on almost all of my sprites and it eliminated the black lines.
    I'm guessing an even better solution would be to expand your textures by 2px and set the transparency of that to 5%, if you can't have a slightly visible outline.
     
  7. MightySheep

    MightySheep

    Joined:
    Sep 23, 2015
    Posts:
    21
    If you have exactly lined up tiles and it is happening, for me helped disabling Anisotropic filtering and antialiasing in Quality settings.
     
    Lord0fSouls, AShenawy, Ten086 and 2 others like this.
  8. jbouker

    jbouker

    Joined:
    Dec 25, 2016
    Posts:
    1
    thank you mighty sheep! Saved my life.
     
  9. Boich

    Boich

    Joined:
    Apr 5, 2018
    Posts:
    1
    Thank you so much for this <3
     
  10. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    It's great to show appreciation but please use the Like button rather than necroing a 9 year old post.
     
Thread Status:
Not open for further replies.