- Home /
Problems with vertex snapping, 2D peoject Unity 5
I thought I posted this yesterday, but I can't seem to find it (yes I looked for my post via my profile). So sorry if this becomes a double post. Anyway~
I jumped back into Unity after a somewhat long hiatus in the world of Blender, and decided to re-import a project that I was working on in Unity 4.x, piece by piece into Unity 5 (I need the practice anyway).
I'm using a sprite sheet 1536 X 1536 and I sliced it into 512 X 512 tiles. I haven't changed the scale of the tiles, they are all default 1,1,1. I am using the v key to vertex snap the tiles.
The tiles vertex snap as you would expect when I do single tiles, but if I bulk duplicate and snap, it leaves about a pixel wide gap at the 15th or so tile. I only noticed it on the X axis but haven't tried to duplicate the problem on the Y axis.
Another problem I'm having is I have tiles that lay on top of some other tiles. I have already set the layer value so they stay "on top" of the other tiles. I noticed that when I snap them into place I start to run into slight offset problems.
Usually when you vertex snap you have to move the mouse to the somewhat extreme to get it to snap to the next vertex. What is happening though is when I snap the tiles on top of other tiles it causes the mouse to become a bit sensitive in that area and starts offsetting my tiles by about 0.02 in either the X or Y axis. I noticed the square on the gizmo also blurs and sharpens when this happens.
I don't remember running into these issues in the earlier release of Unity.
So, is this some kind of feature I have to disable/tweak? If so, how would I go about changing it? Or is this a bug I should report?
Thanks
EDIT:
I removed the previous post I had on this problem, the mods finally approved it after 20+ hours so I thought it was MIA. I'll keep this one instead.
I tried to get around the above problem by just setting the snap setting to 5.12 X 5.12 Y (size of my tiles) and I'm getting the same issue on the 15th tile.
I think the problem can be reproduced if you have all the tiles in the same spot then snap them across one direction.
For some reason it looks like Unity is rounding the float numbers at some points creating 0.01 space gaps between tiles.
Answer by Sebastian_Miko · Apr 01, 2015 at 04:41 PM
Scroll down to TLDR Solution if you just want a solution and rather not read.
I had the same issue, although it didn’t wait for 15 sprites to show spacing. The issue was random for me, sometimes spacing showed, and sometimes it didn’t. But it was guaranteed to show at some point for EVERY vertex snap. For me, this is unacceptable in game.
I spend several hours troubleshooting, trying all types of different scenarios Texture Atlases (Sprite Sheets) and Single Sprite Mode - sprite on an individual Texture.
From my troubleshooting my findings were
The issue OCCURS when:
You use a sprite from a Sprite Sheet / Texture Atlas, and that Sprite does not take up the entire width or length (depending on where you actually want to snap to) of the Sprite Sheet / Texture Atlas
The issue does NOT OCCUR when:
You use a sprite that takes up the entire width or length (depending on where you actually want to snap to) of the Sprite Sheet / Texture Atlas it is on
You use a sprite that has its own Texture (Single Sprite Mode).
Conclusion It seems to me that Multiple Sprite Mode is flawed in terms of vertex snapping, unless your sprite actually takes up the width and length of that sprite sheet.
TLDR Solution
Use individual Textures for your Sprites
(Unity 5.0 automatically creates one Sprite Atlas when building the game, so creating Sprite Atlases are no longer necessary for performance reasons). I realize it may be necessary for other reasons.
If you must use Sprite Sheets -
a. Have the sprite take up the entire width or length of the Sprite Sheet depending on which axis you’re snapping to
b. Scripting - above my pay grade
Thanks for the response and tips Sebastian. I never tried to slice my images in Gimp/Paint so they made up a single tile, but I may try that later.
I forgot to post this, but I think the distance of the camera plays a part in the gap process.(or at least for me it dose)
I found kind of a workaround myself about a couple of days after this post. I noticed that if I leave my camera at a fairly close distance to the tile and snap, the sprites don't get gaps and they align properly.
So I snapped all my "ground" sprites in blocks of four and parented them to one of the blocks, then snapped the parent. the problem is still there, but I got around it by limiting the amount of snapping and keeping the camera zoomed in. Still a pain when I do bulk snapping...
I'm glad I'm not the only one having this problem. Hopefully the Unity $$anonymous$$m notices and fixes it in the next update.
Your answer
Follow this Question
Related Questions
Vertex snapping while resizing 1 Answer
How to Vertex-Snap the corner of a Sprite-Shape 3 Answers
Vertex snapping of any mesh at runtime 2 Answers
Procedural Vertex Snapping 1 Answer
Snapping UI sprite? 0 Answers