Independent Tile Properties

Hello!

How can I do ‘independent’ tile properties? What I mean is, in a Tile Layer, I want to add custom properties to the tile itself (the button is grayed out).

I can sort of do the same thing with object layers and tile, but I want to use a Tile Layer as object layers aren’t ‘fixed’ to a tile. (the objects uses x/y coordinates instead of tile coordinates)

Sample usecase: Add a ‘chest’ tile where I add the property ‘sword_001’ (which is read by my script).

Hi,

It’s not possible to set properties to a tile in a tile layer.
A workaround is to use an object layer and place a tile object (an object that is a tile) using absolute coordinates.

See: https://doc.mapeditor.org/en/stable/manual/objects/#insert-tile

1 Like

I was afraid that’d be the case. It’d be great if we could get this, or alternatively, allow tile painting on events. While Tiled Objects work, I much prefer if I could ‘paint’ event tiles and have them be positioned relatively

Doesn’t enabling “Snap to Grid” in “View -> Snapping” solve this issue for you?

Though note that due to the origin of tile objects being bottom-left, you’ll probably need to do -1 after dividing the object position by the tile size (if you need the tile coordinates in your game).

Thanks! Yup tile snapping sort of solves it, but I think it could still be useful to have it be in a tile layer. One reason is relative positions would allow easy resize of tile maps (though I admit the use case is rare and can be worked around).

One question though - it seems like when using tile object, the tile data Is not exported to json:

{
                 "gid":32,
                 "height":48,
                 "id":8,
                 "name":"DavetownGate",
                 "properties":
                    {
                     "davetown_gate":"tut"
                    },
                 "propertytypes":
                    {
                     "davetown_gate":"string"
                    },
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":48,
                 "x":288,
                 "y":336
                }

This could be potentially useful as to allow parsing of object tiles without adding custom properties

If you resize a map, Tiled does make sure to move the objects as appropriate as well, but I agree having data on tile layers could make this work better in more cases (like copy/paste of stuff).

Actually the tile data is represented by the gid property. It is a global tile ID, of the same kind you find in tile layer data.

Actually the tile data is represented by the gid property. It is a global tile ID, of the same kind you find in tile layer data.

Funny, I actually came back to this thread to edit that because I realized this! I thought of using it at first, but it returned the wrong tile so I just thought it was a global object id. Then I realized it was zero index and I was good to go!

If you resize a map, Tiled does make sure to move the objects as appropriate as well, but I agree having data on tile layers could make this work better in more cases (like copy/paste of stuff).

Oh nice I didn’t realize this, though that doesn’t seem to be the case when I tried it. To be clear what I did was to edit the tile size (i.e. 48x48 to 24x24). It might be that it only works for map dimension changes and not tile size changes?

It’s not exactly that, it’s a global tile ID that may refer to a tile in any of the tilesets loaded by the map. It ends up shifted by one compared to the tiles in the first tileset, because global tile ID 0 is taken to mean “no tile”.

Ah, yes, it only works when you change the map dimensions, not the tile size. I guess it could be interesting to support adjusting object positions to a change of tile size, but that is a really quite a rare operation.

2 Likes