I have a tilemap and sprite object (both are in the same layer) and positioned it using snap to grid, when in editor it looks perfect and seamless but when the game is run there is some gap between them.
No problem when in editor:
(The small vertical line in the left is just camera boundaries)
The image for the object is 32px the grid is also 32px, I think there is no problem with the tilemap either.
My solution for now is to move the wall at the left to the right by 1px.
How did this happen? Shouldn’t using snap to grid will position the object perfectly?
When you say snap to grid, you mean you’re using the events snap to grid or just the grid in the editor? If I use snap to grid in events it never matches what’s in the scene editor. I have walls going up vertically from my floors and it is just impossible to set them up in editor because they look great (well not great because not ysorted lol) but the snap to grid for the floor in the events moves the floor to a different grid than the editor so the walls are not connected to the floor anymore. The only way I can do the walls is create them with events after the floor snapping is done at the beginning of scene.
From what I gather though, this is expected behavior.
The only time I notice “offness” between what I see in the editor and the preview is when the, I don’t know if this will make sense, something about the origin points. Well anyway I’m not sure what happens, and it shouldn’t be happening here because I don’t suppose your events use anything that calculates position of these objects. Hopefully someone else can shed some light on this.
Low res games used to have some display issues, I’m not sure they all got fixed, and tiled sprites used to have some too. I don’t know about tilemaps.
If my memory is correct, the issue was related to the smooth camera features. Do you have anything similar? Camera motion, or anything with lerp()?
In my current project, I overlapped the main texture 1 pixel over the border textures to avoid such issues. Maybe you can do the same?
If you check in the debugger the positions and sizes when the issue is visible, do they add up? Meaning, there shouldn’t be any gap.
Oh I discover something, when I use sprite object and tilemap there is a gap but you know what?
When I export my Tiled project as Image and use it as sprite object (instead of using tilemap) it works! No gap, no problem, it connect seamlessly. Magical.
I wouldn’t be much surprised, tilemap is a recent feature, and tiled sprite had a similar issue.
That being said, on your screenshot, it looks like your two ground textures are not aligned, which would explain the gap.
Wow I used snap to grid though, so the problem is the tilemap object (ground texture above).
The dimension of both are the same, no probs with the x position (when checked in the debugger), so maybe tilemap in general still need to be improved (assuming that I didn’t make any mistakes).
Well thanks anyway, I am still gonna keep using the tilemap object and just move it 1px to the left.