- Home /
Pixel snap and anti-aliasing not working?
So I've been having an issue with lines in between my tiles in my 2D game. The go-to fix is usually to turn off anti-aliasing in project settings and turn on pixel snap on everything, but somehow pixel snap has made the lines more pronounced then they were before. Anyone else had this problem?
This (above) is what the game looks like with pixel snap on; the lines are permanent when my character walks. Without pixel snap, the lines just flash in and out.
Probably a stupid question, but are you sure your tile image doesn't have a line of missing pixels at the bottom? The only breaks in the line appear to be from possibly a slightly taller tile below.
Just a thought, -Larry
I don't think so, because when I have pixel-snap off the lines only appear intermittently. Here's a snapshot of a frame that's fine when pixel snap is off:
I would take a look up close at the tile images just to be sure. with pixel snap off, it may be allowing more overlap, hiding the line.
Answer by SamFZGames · Jan 14, 2018 at 03:17 PM
Hi there, sorry it took a while to get an answer for this one, I just found this, but if you didn't already work it out I can sort this one out for you.
When scaling sprites to particular resolutions, sometimes Unity uses a little bit of whatever's around the edge of the sprite in your texture when scaling up (something to do with the resolution not being an integer multiple of your sprite's resolution), so what you're seeing there is either a piece of the tile you have stored above it in your tile sheet, or transparency. Seems like the former when you look at how above your trees there's a brown line and it's black above everywhere else.
The solution is to separate your tiles from one another, have a gap between each tile of 2 pixels or so, and add some 'bleed' (padding) to the edge of each tile. For example you'd want to put a 1 pixel border of green around your grass tiles, or if the tile is complex then just copy the edge pixels. Then Unity will fill that tiny pixel gap with that colour, and it will be unnoticeable.
^ Here's an example with some tiles of mine. The blue line shows where Unity slices them. I have 1px extra pixels around the edge of every tile. Do this and Unity will stop giving you those lines.
Super Tilemap Editor on the asset store comes with an atlas editor feature that can do this for you in a couple of clicks.
Your answer
Follow this Question
Related Questions
Lines at the top of sprites 3 Answers
How to get better sprite quality without turning on anti-aliasing? 0 Answers
Dynamic Interactive 2d World Map 0 Answers
Crop/Mask a Sprite on runtime 0 Answers