• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
9
Question by rastating · Jan 05, 2014 at 04:17 PM · 2dspritetilesalignmentz-fighting

Gaps sometimes appearing between 2D sprites

When the camera is moving, both in game and in the Unity editor, 1 pixel wide gaps between my sprites will appear (see enlarged example below). I've read this is potentially due to z-fighting, and I have tried altering the clipping settings on the camera but the problem still persists.

Can anyone shed some light on why this may be occurring?

Extra info that may be of use:

  • The sprites pictured have been imported using a single sprite sheet which has a texture type of "Sprite" and a sprite mode of "Multiple" and the filter mode is set to "Point".

  • The background that can be seen bleeding through occasionally (the 1 pixel gap) is also imported as a sprite but with a sprite mode of "Single". I have tried with the filter mode set to both "Point" and "Bilinear" but both produce the same problem.

  • When positioning the tiles, I held down the "V" key to make them snap together, I have zoomed in as far as possible and can't see any gap between the tiles when doing this.

alt text

gap.png (3.4 kB)
Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Jan 05, 2014 at 04:48 PM -1
Share

Nothing at all to do with z-fighting.

avatar image Corbeau · Feb 10, 2014 at 04:48 AM 0
Share

I have the same problem and have not found a solution. Still looking.

avatar image ARN · Mar 11, 2014 at 07:03 PM 0
Share

same problem here... I tried "pixel snap", "point" vs compression, playing with AA, different camera setups, ... to no avail. This really needs some clear answering from someone!

avatar image TrevorP · Mar 11, 2014 at 07:24 PM 0
Share

What are your Pixel To Units field set at on your imported sprites? Are you scaling them in game? I'm thinking it might have something to do with a combination of Pixels To Units and the size of the object on screen. $$anonymous$$ight cause a rounding issue where it's shaving a pixel off the sprite when rendering to the screen in game

14 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by Zulrang · Feb 26, 2018 at 02:20 AM

In the sprite, change the filter mode to "Point (no filter)"

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Feb 26, 2018 at 02:23 AM 0
Share

"I have tried with the filter mode set to both "Point" and "Bilinear" but both produce the same problem."

avatar image
0

Answer by itsdavidch · Jun 16, 2019 at 06:24 AM

In my case the problem was caused by the Pixel Perfect Camara Script(one of Unity's non-built-in packages), so just turnning it off solved it

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Mytino · Aug 08, 2019 at 04:23 PM

A bit of a special case which might not have been mentioned by others: If you are creating Texture2D objects during runtime, they default to using mipmaps with their short object constructor. For me, this resulted in gaps between tiles for my custom tilemap shader at specific camera positions (the Texture2D in question was my tilemap atlas). Took a long time for me to figure out, but it was just a matter of marking false for the mipChain bool in one of the longer Texture2D constructors. More info here: https://gamedev.stackexchange.com/questions/172297/how-to-change-texture2d-type-to-sprite-during-runtime-unity

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by ChemicaLabs · Nov 16, 2019 at 04:03 PM

Anyone still suffering from this issue can try this free utility from the asset store.

https://assetstore.unity.com/packages/2d/textures-materials/2d-tile-gap-fixing-tool-157060

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • ‹
  • 1
  • 2
  • 3

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

46 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Pixel Perfect 2 Answers

How to performantly render 1000s of sprites? 0 Answers

Make Tiled Sprite expand in all directions 0 Answers

Is there another way of making a Top-Down-2D Map other than generating hundreds of Spriterenderes? 1 Answer

Issue with outline size using sprite tiles 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges