How to make 2d tilesets work well PLEASE HELP

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Vickyboi

Im making a 2d platformer in godot 4, but there is one HUGE problem
The tilemaps aren’t cooperating

Notice how the orange boxes are slightly off
This is really annoying because this makes collisions difficult to set up, and the tiles mesh together when painting them.

:bust_in_silhouette: Reply From: malaska

It’s hard to know for certain due to the cropping of your screenshot, but I think the following is happening:

Looking at your screenshot it appears that you have 24x24 pixel tiles, with 1 pixel margin around, and 2 pixel space between.

It also looks like you are using the separation settings to try and get your tiles to line up.

It appears that the 1 pixel vs 2 pixel spacing is what is causing your issue. I bet if you moved all your tiles (in your sprite sheet) 1 pixel to the right, and one pixel down you could get them to work. You might need to adjust your Atlas settings to account for the change a little.

Alternatively you could remove all spacing around your tiles, so that their edges “touch,” and make sure your tiles fit a 24x24 grid before importing them.

I find that making my grid size match my tile size, and not adding space between tiles, is the easiest way to avoid issues like this. Here is an example of a texture atlas I have set up in a Tileset as an example:

In my screenshot you can see that my tiles are 32x32, and I have no margins or separation. Where I do have transparent tiles/spaces, they will all be 32x32 blocks as well, so my grid isn’t disrupted.

I hope this helps!