Tilemap Border Size

Hello there

Can’t find anything about this on the internet. I have created a 2D RPG using tilemaps. I am using a script to figure out the size of the tilemap and then using the size to prevent my player walking off the edge, it works fine on most levels.

But on some levels the tilemap dimensions are not being recorded properly and the player is able to walk off the edge. I think the problem can be seen in this screenshot, you can see the edges of the tilemap are much bigger than the actual painted tiles…

So, how do I make this blue box neatly fit my tilemap and not leave all that empty space? Any help gratefully recieved.

Note: If I simply grab and push the sizing handle it resizes all of the tiles in my tilemap and still leaves the same empty space at the edge.

“…” → “Compress Tilemap Bounds” 178011-screenshot-2021-03-24-at-011558.png

Don’t worry, sorted, here is the solution…

Firstly double check that you don’t have ANY rouge tiles that you’ve added by mistake (sometimes the same colour as the background) use a temp tilemap collider to highlight all of your tiles. Once you’re certain.

Enable debug mode. Click on your Grid (or any object) just above the word “Static” in the properties window click the 3 dots (next to the padlock) and select Debug.


Once you can see the debug options you can then use the tilemap Origin and Size properties to adjust the box.

Hope this helps.