MonoGame.Extended icon indicating copy to clipboard operation
MonoGame.Extended copied to clipboard

[TiledMapRenderer] Misalignment of tiles when using different tilesets of different cell sizes

Open SilenceOfTheLambdas opened this issue 4 years ago • 8 comments

If you add tiles to a map (32x32 grid) from a tileset that uses a 32x32 grid, the map will render perfectly. But, if you then add some tiles to your map from a tileset that's a different size (i.e. 64x128), those tiles will be misaligned.

When using tiles only from tilesets that match the map's tile size (32x32) Game: image Tiled Editor (How it should look): image

When using tiles from a tileset that matches the map tile size, and some tiles from a tileset that does not match the map's tile size Game: image

Tiled Editor (How it should look): image

SilenceOfTheLambdas avatar Oct 19 '20 17:10 SilenceOfTheLambdas

Interesting. Could you post the project with the files used for testing this?

lithiumtoast avatar Oct 22 '20 04:10 lithiumtoast

Interesting. Could you post the project with the files used for testing this?

Here is a link to the repo: https://github.com/sudo-make/Capstone-Project. You should just be able to import the project using Rider.

SilenceOfTheLambdas avatar Oct 22 '20 10:10 SilenceOfTheLambdas

Reproduced. The problem is the position of the vertices when building the GPU memory from the tiled map's data.

lithiumtoast avatar Nov 03 '20 18:11 lithiumtoast

Is there any update on this issue? Currently running into it myself now.

Uraxys avatar Jun 17 '21 20:06 Uraxys

I believe the issue was resolved in offline communications.

@Uraxys could you send me a project with this issue? I'll take a look.

lithiumtoast avatar Jun 17 '21 23:06 lithiumtoast

I believe the issue was resolved in offline communications.

@Uraxys could you send me a project with this issue? I'll take a look.

Here you go https://github.com/Uraxys/MonoGameDemo

Here is also a picture of how it should look compared to what it looks like in game. (In tiled) Picture1 (In game) Picture2

Uraxys avatar Jun 18 '21 16:06 Uraxys

Update: I was able to fix the issue by adding this line inside the CreateTileLayerModels method in the TiledMapModelBuilder class. It makes larger tiles "go" upwards instead of downwards, as that was my issue.

if (tileset.TileHeight > tileLayer.TileHeight) tilePosition.Y -= tileset.TileHeight - tileLayer.TileHeight;

No idea if this is the best solution, but wanted to share it incase it helps fix the issue.

Uraxys avatar Jun 21 '21 11:06 Uraxys