Imported Tiled Map Off by 0.5 in Each Direction

Hi there,

I have been working on getting a setup I like for a simple map for a small hobby project. For better or worse, my current flow is to have a single layer map in Tiled where I can draw the general shape of my map. I then import that map into Unity using SuperTiled2Unity.

The issue comes with when I then try to “duplicate” that single layer into a new tilemap inside of unity via code. For a number of reasons, I do not want to have two layers in Tiled. I want to simply duplicate a single map during import to Unity onto a separate Tilemap. I am using a custom importer script with SuperTiled2Unity, but that shouldn’t have much of an impact on my question as it is more about how Tile positions are represented in Tiled compared to Unity.

So with my goal in mind of duplicating the map from Tiled into a separate Unity Tilemap (while maintaining the imported Tilemap as well), here’s the core of my issue:

In my custom importer script, I am basically doing the following steps:

  1. Get the object that represents my single layer Tilemap that is coming from Tiled
  2. Create a new GameObject with a Tilemap component programatically (this game object has the same position as the imported Tilemap mentioned in the previous step) that is a child of the same Grid that the reference tilemap is a child of.
  3. Loop over all Tile positions in the reference Tilemap (from the first step)
  4. For each position, set the tile in the same position on my new Tilemap to a simple tile.

From the code, I would expect the two tilemaps to be exactly the same (except for the tiles that they are comprised of) and be perfectly aligned on the grid. However, what I get is what you can see in this image:

In the above, the orange tiles are from the reference tilemap and the pink tiles are from my “duplicate”. As you can see, the duplicate is off by 0.5 on the X and Y axes. I’m confused by this. I have played around with the Tile Anchor and such to no avail.

In my head, this feels like it is a difference between how Tiled identifies a Tile’s position in the Grid and how Unity places a tile within a grid. Why are they not the same if the Grid is the same Grid and the “position” of each tile is the same??

I would appreciate any insight into this, and thank you in advance!

(Grain of salt alert: I am clueless about Unity.)

It seems like you’re positioning the tiles in the cell’s centre, but the tiles in Tiled are positioned relative to the top left (or rather, bottom left - tile height, but that’s the same thing in this case where the tile height equals the cell height).

Thanks for the reply. This would make the most sense. I’m unsure how to position a tile based on bottom left rather than the center in Unity, but I think this is my issue for sure. Thanks for the input, much appreciated!