How to access collision data from tiled maps


I’m starting to use monogame extended and it going great until i started adding collision detection to my game. This is well supported in tiled with objects you can overlay on each tile or alternatively create another layer of objects. Whichever method I pick, I still cannot access this data in monogame. The only workaround i’ve found is to do:

Assets.Maps["Level1"].GetLayer<TiledMapTileLayer>("Collision").GetTile(Convert.ToUInt16(position.X), Convert.ToUInt16(position.Y)).IsBlank

on the collision layer. This isn’t elegant and restricts what you can do. So i’m wondering if there is something i am missing.


I’m having some issues with the code i posted, turns out objects are not in the TiledMapTileLayer, they have a TiledMapObjectLayer. The methods for this class are sparse and contain no obvious way to use them for collision. Seems as though objects weren’t designed for collisions. This begs the question what is the way to do collision?

1 Like

The way to do collision is by not using mg.ext tiles library. It’s plain garbage.

That’s not really answering the question, how would you go about doing it?

1 Like

I wrote my own Tiled integration – but it’s coupled with my engine.

I would say a tile renderer is not that hard to implement and is probably worth writing your own just so you have full control over it. I remember doing it over a weekend.

Main part is you want to try to group all your tiles in one texture, it’s more efficient for the gpu that way.