I’m using Tiled 1,11,2. When I save a tile object as a template, the global id in the template is sometimes different than in the tilemap itself, so the objects don’t render with the correct sprites. If I don’t save objects as templates, the global ids are correct and everything renders fine. Attached is an image of an object from the tilemap and the same object exported as a template. The global id is 161 in the tilemap file and 17 when exported as a template.
Templates cannot use the same GIDs as the map, since they don’t know the tilesets used in the map (and may be used in many maps which assign different GIDs to the same tile). They list their own tileset and the GID is relative to that. Perhaps you’re just using the wrong tileset listing when calculating the tile to display? The tileset entry you should be using for the template is visible in the screenshot of the template that you posted.
Ok, I got it to work, thank you.
Actually I do have another question - the firstgid value in the template file doesn’t match that of the tileset, it always seems to be 1. I assumed this was something I was getting wrong in the editor settings but I can’t get it to sync with the tilemap.
Because templates contain only a single Object, and a Tile Object can only use a single tileset, the firstgid for a template will almost always be 1, since there are no other tilesets to push that firstgid up.
As I wrote earlier, the firstgid value in the template file has nothing to do with the firstgid values in the map, the two have independent lists of tilesets. Use the map’s firstgids for any values stored in the map (including any overrides of the template’s values), and use the template’s firstgids for any gid values stored in the template.
Do not expect firstgid to match between different files, there is no reason they should. Maps and templates are different files.