How to change Tilemap centre?

How to change Tilemap centre?

I’m trying to make a 2D Dungeon Crawler game and want to randomly generate the dungeon. I’m designing the dungeon sections in tilemaps and want to save them as prefabs to use them when they get generated.

I’ve read about connecting the tilemap to a parent object so it can link to the objects local coordinates. This works fine and I can make the prefabs. The issue lies when I place the prefab. The prefab seems to be registering a lot of blank space that I don’t want.

I was wondering if there was a way you can change either the size of the tilemap itself, or to change where the centre of the tilemap is?


You can see the size of the tilemap when I am using the rect tool.

Hello,
The rect tool shows the bounds of an object and updating that is a rather expensive operation on a Tilemap so it is not called automatically

You could try clicking on the menu dropdown on the top right of the Tilemap Component within the Inspector and select Compress Tilemap Bounds
8501645--1132118--Unity_76BRHrmuqs.png

Or if you’re doing it through script, you can also call the Tilemap.CompressBounds() method

2 Likes

Hi Daniel,
That has worked perfectly! Thank you so much, I was scratching my head over this for 3 hours XD

1 Like