I am making a game similar to Rimworld and I have issues aligning the tilemap, grid and sprites so that they all work as intended functionally and visually.
The default offset for the tile anchor
is 0.5, 0.5, 0
and this works entirely until I drop a sprite in the center of the tile, where it appears to be positioned bottom-left (with the sprite's pivot set to Center
).
This is a problem because I'd have to manually set an offset (0.5, 0.5, 0) for every single object I instantiate to match the visuals of the tilemap. I tried setting the tile anchor
to 0 but then the tilemap moves while the grid position stays the same which messes up click detection. (if only I could move the grid back by (-0.5, -0.5, 0)?
Is there an elegant and easy solution for all of this?
To get a perfect custom alignment for a tilemap or sprite the easiest solution is to take a empty gameobject as spawner , take the position of that empty spawner object and and then instantiate those tile or other prefab at the exact location where you kept those spawner objects by your choice.