Any way to move (Cut/Paste) objects from Object layer to a Tile layer instead?

Hey there!

I’ve been using LEd 2D Map Editor to create my levels because the UI/UX is a lot more intuitive to me than Tiled was (especially when it comes to the nightmarish archaic implementation of Rule Tiles/“automapping” of Tiled, compared to the UI driven Unity-like approach LEd takes). So in my digging to learn how to best import my levels to Unity, I discovered that LEd has an option to save the same level for use in Tiled, like so.

Afterwards I discovered SuperTiled2Unity, and thought it would be a perfect solution for me. I can use LEd to make my levels, save them as a Tiled TMX, then use the aforementioned Unity Package to simply drag and drop my levels into Unity.

It worked! … sort of.

It wasn’t behaving the way I was expecting it would, so I opened the TMX in Tiled to try and figure out what the issue was.

As it turns out, LEd saves the level’s layers as Objects instead of tiles in the TMX file. After metaphorically ramming my skull into a brick wall for the last half an hour trying to figure out how to move / copy / cut / paste / transfer / merge the objects into the Tile layer instead, I’m at my wit’s end. So here’s the question:

Is there ANY way to do what I’m trying to do? How can I simply take the objects (every single tile sprite you see is a separate object) and move them into a Tile Layer instead of an Object layer?

As a separate question, while I’m thinking about it: I’m utterly baffled and confused by how to create colliders in Tiled. Is there no way to assign collision to a tilemap/tileset? Like make it automatically ignore transparency and “shrink-wrap” collision around the edges of all the sprites?

You could write a script to go through the objects, read their tiles, and put them in the cell corresponding to the object’s location, I think. There’s no built-in way that I’m aware of. Can LEd be scripted or set up to output regular tiles instead of Objects, perhaps?

You can assign collision by editing the tileset and using the collision editor. I don’t think there’s an automated way to do it based on transparency, though (probably because for most tilesets, that gives a garbage result).

Also, FWIW, Tiled’s automapping is the unapproachable mess that it is in an effort to preserve flexibility, its automapper can do things that others cannot. The cost of this is an awful UI. It would be nice to have wizards/GUIs for common scenarios, but the core problem isn’t that it’s archaic, but that it’s trying to do more than can be contained in a nice GUI.

Hey @Brandon_Graham, welcome to the Tiled community forum!

As far as I understand, LEd’s export works with objects because its author did not care to produce a more optimized version, even going as far as writing in the documentation that it’s due to missing features in Tiled:

All tiles in LEd are exported as Tile Object in Tiled . I don’t use the classic tile layer at all. Here are the reasons behind this choice:

  • Tiled doesn’t support different grid sizes in the same Map: you can’t have some tiles on a 8×8 grid layer, and some others on a 16×16 grid layer.
  • Tiled cannot have multiple tiles in a single cell.
  • Tiled doesn’t support tiles positioned using free pixel coordinates.

Really, this documentation is mostly wrong. Especially the last point is really strange, because it’s exporting to objects which are explicitly a way to position tiles using free pixel coordinates. Tiled can also have multiple tiles in a single cell, you just need to use multiple layers in that case.

The only point which is currently correct is that you can’t have different tile sizes per layer. While this is something I’m interested to support in the future, it’s really a rare case and there’s no reason LEd couldn’t simply export to tile layers in the common case where all layers use the same tile size. It could even do this when that is not the case, which will make the map look a bit broken in Tiled, but when it would just write a tilewidth and tileheight attribute on the exported tile layer then it could be eventually supported by Tiled or any other TMX-supporting library like SuperTiled2Unity.

The docs also say “IntGrid” won’t be exported “as this feature doesn’t exist in Tiled”. But there’s really no difference between an “IntGrid” and a tile layer, except that you need a tileset with colored rectangles to represent each integer value. It should be trivial for LEd to export such a tileset.

I find it rather unfortunate that LEd’s author decided to essentially bash Tiled in its UI and documentation, especially given that both tools are open source there could be a much more friendly relationship between the tools.

In the latest development snapshot, Tiled can automatically set a bounding box based on pixel transparency, but it can’t “shrink-wrap” a collision shape yet. It is definitely something I’d like to support, but in the meantime you can just place a polygon manually. Given the shapes of your tiles I expect this should be quick and easy and would probably work better than an automated solution.

1 Like