SuperTiled2Unity icon indicating copy to clipboard operation
SuperTiled2Unity copied to clipboard

unity:layer option not applying to children

Open xThuby opened this issue 3 years ago • 2 comments

I've got a Tiled map with a layer for collisions. These should be assigned to the Ground layer in Unity but although the tilemap becomes assigned to that layer, it's children does not, which causes collisions to not work.

image

image

xThuby avatar Feb 13 '22 00:02 xThuby

Hi there, @OliverAThunes. Sorry for the late reply.

I just did a quick test and the layers are applying to children. I wonder if you have a unity:layer custom property not only on the Tile Layer but on Tileset properties or maybe within the separate tiles (in the Tiled Collision Editor)? Those later properties will take precedence in that case.

If that doesn't help maybe you can send me your Tiled files and I'll see if there's a bug somewhere. Thanks.

Seanba avatar Feb 27 '22 19:02 Seanba

Hi, I also have this exact problem. Here are my files: https://drive.google.com/file/d/1fxSPX299MuC9GXJpFXsszhWzgNXNubh6/view?usp=sharing

EDIT: I decided to do some debugging through the editor code and found that ProcessObjectGroupElement() only considers the tile hierarchy level for collision layers, it's not aware of its context within Tiled layers at all. Which means that if the individual tileset tile doesn't have an object name or unity:layer property then there it will be set to "Default". That is really different logic to what's described in the docs, the expectation is that layers would apply to all their children and grandchildren, and then children can decide to individually override those. I've worked around it for now by defining the unity:layer on every single tile sprite in my game.

rocifier avatar Apr 02 '22 04:04 rocifier