Cammin / LDtkToUnity

Unity importer for the LDtk level editor
https://cammin.github.io/LDtkToUnity
MIT License
388 stars 39 forks source link

Tile gap help #22

Closed stickynoteme closed 3 years ago

stickynoteme commented 3 years ago

For some reason I can't figure out how to get LDtkUnity to not put a transparent gap between tiles.

attached a photo of the issue in unity, and a photo of what it looks like in LDtk.

gap Looks like in LDtk

stickynoteme commented 3 years ago

and here's the png I'm using for the tileset in case it helps LDtk_level_001_tileset_min

Cammin commented 3 years ago

Hi, I might have to shed some light on this.

This is an issue related to how sprites are sliced. The edges has open space on all of the tile's sides in the texture which is what gives that seam gap appearance.

The solution is to use a sprite atlas with the importer. It adds padding to sprites assigned to it so that the slices no longer have the gap issue, and is also more optimized 🙂

More details here https://cammin.github.io/LDtkUnity/documentation/Importer/topic_Section_Main.html#sprite-atlas

I might try to make a special documentation topic that talks about this specifically. Thanks for reporting this issue.

stickynoteme commented 3 years ago

Thanks for the tip, great appreciated!

Made a sprite atlas and assigned it to the LDtk file.

It certainly reduced the issue, but unfortunately it's still there.

helped

Cammin commented 3 years ago

Hmm, maybe try increasing the padding size in the sprite atlas further. I've had that fix my tearing problems sometimes. Also, I noticed in the screenshot that sprite atlas packing is disabled. I'm not positive it'd fix it, but it may. I think it allows you to manually pack from inside the inspector. 🙂

Also, another important detail I remembered, is that the packing only works in the scene/game window if you are in play mode. (I remember getting confused by this as well)

If it still doesn't work, then I will test with your tileset sometime later today to see what happens. 👍

stickynoteme commented 3 years ago

Again really appropriate the help.

Turned up padding to it's max 8x8 and enabled tight packing

This is an in game screenshot, which is getting closer, though still has tearing on some sides...

I added a block of tiles made with the same quick prototype tileset using Unities built in tile system to try and make sure it wasn't some other project setting, but it turned out fine with no tearing.

Game window result

Cammin commented 3 years ago

It's definitely interesting. I've been trying to address this tearing for a long time, but it keeps showing up 😅

Ensure you have the sprite packer mode to Always Enable, just in case that's the issue.
https://docs.unity3d.com/2017.4/Documentation/Manual/SpritePackerModes.html

Also try using Unity's pixel-perfect camera, which might also fix this problem.

But yeah, I'll be checking this out later sometime. Thanks for the information. 🙂

stickynoteme commented 3 years ago

And got it!

Sprite packer was set to enable for builds.

Thanks a ton for the nudges, I'd been trying to figure that out for days. XD

Cammin commented 3 years ago

Awesome, I'm glad it was able to work out. 👍 Yeah, feel free to post issues if you're ever stuck with something. Also, I'd be interested in checking out your game if you finish it. I see you're using Corgi. 🙂 Also can try contacting me on discord. I'm in the LDtk discord, can find me from there.

Cammin commented 3 years ago

I updated the documentation with this tilemap tearing topic in mind. This discussion helped build it 🙂 https://cammin.github.io/LDtkUnity/documentation/Topics/topic_TilemapTearing.html

stickynoteme commented 3 years ago

Awesome, hope it helps other people as much as it did me. :D

And indeed, I started out in Godot, but I've been having a lot of shoulders/wrists/finger issues from spending too much time typing, so I moved over to Unity + Corgi + LDtk so I could spend more time tweaking pre-made systems and only making code for things I really needed to. Overall it's been fun and I'm starting to get far enough into things that it feels like I'm making real progress.