Tutorial: Unity2D Tiling and Those Gaps…


If you’re new to the Unity2D engine (4.6 and Up), you may be daunted about the online tutorials that may, or may not, go into depths about the intricacies of the engine. This is reasonable; there are a lot of gotchas that are within the engine itself, especially if you want to work in a 2D format. The largest complaint with Unity 2D is the gaps that occur when tiling from a sprite sheet. How do you get rid of them? There are so many answers and solutions but none of them work? Do you buy asset app from the Unity store or can you do it yourself?

Have no fear; you can – and should – do it yourself though it takes some delving into the UI to get what you need. My solution is for Unity 4.6 to 5.X.X and it follows Matt Schell’s (@mattmirrorfish) Rogue Like 2D tutorial. Note: I want to just give a heads up that Matt’s tutorial is not for beginners, so take the negativity in the comments with a grain of salt. I’ve you’ve been coding for more than two years, the concepts are sound, but there are a few nuances that are Unity 2D engine specific. If you’re new to the engine and don’t have a good lay of the land yet, this is for you.

The Problem: Those Damn Gaps

If you follow Matt’s tutorial, specifically Number 5, you may run into following when it comes time to test your layout:

Unity2DGridpuhri1

Jebus…thems some gaps. Before throwing in the towel, there are two solutions you should try.

 

Solution 1: Turn off Anti Aliasing

Unity2DGridpuhri2

Navigate to Edit > Projects > Quality and untick the Anti-Aliasing box. Restart the engine and see the magic!

 

Solution 2: Check Your Pixel Spacing On Your Sprite Sheet

Unity2DGridpuhri3Go to your projects folder as I did above and check the Pixel Per Unit number! I found that my number was automatically 100 when it should’ve been 32 (the sprite sheet tile size). Reference the tilesheet, not the actual tile itself. Once I changed my PPU number and turned off Anti-Aliasing, I had not problems! Everything was flush and life was sweet.

Unity2DGridpuhri4

Solution 3: Other Outlier Resources

Granted, Unity2D still has a few kinks and not everything is worked out, so the above issues may not work for you. Don’t lose heart; there are multiple folks having the same issue and they’ve come up with their own solutions as well. Check out the links below:

***

I’m not above asking for tips!

Bitcoin: 1zcqAZaq99XYnWdDCWsYEVX4rwb5ikyvz

Doge: DKERrZi1VLbaJovo6xFWz76dQq3826DP93