Seanba / Tiled2Unity

Export Tiled Map Editor (TMX) files into Unity
Other
497 stars 120 forks source link

Tiled Object Collider Types -> Unity Layer. Always "Default" #102

Closed stephen-moyer closed 6 years ago

stephen-moyer commented 7 years ago

Hi,

This is more of a question(could be a bug, not sure).

So I've got an Objects layer inside Tiled, and I'm adding images to it with colliders defined on them. The colliders have their Type property set to "Obstacle". When I import into Unity though, the objects with colliders in Unity aren't on the Obstacle layer, they're on the Default layer.

If I add these images to a Tile layer, the layers are set correctly inside Unity.

I've found the code where it assigns layers to tile images on objects here

So it looks like I need an Object type on my map that matches "Obstacle", otherwise it's going to just use "Default" as the Unity layer. Is that behavior correct? I would think that it'd just assign that collider object's Unity layer to whatever the "Type" property is, like it does for images on tile layers.

Seanba commented 7 years ago

Hi Steveadoo32, the expectation is that your TileObject will be on the Default layer but will have game object children that have collisions on them with the proper layer applied. This is because a tile can have collisions of multiple types on it, so it needs to be broken down.

Are you seeing something different?

stephen-moyer commented 7 years ago

Hi,

The layers for the Collison object is not on the layer I define in the type field in the Tiled collision editor window.

It's always on the Default layer.

On May 28, 2017, 19:01, at 19:01, Seanba notifications@github.com wrote:

Hi Steveadoo32, the expectation is that your TileObject will be on the Default layer but will have game object children that have collisions on them with the proper layer applied. This is because a tile can have collisions of multiple types on it, so it needs to be broken down.

Are you seeing something different?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Seanba/Tiled2Unity/issues/102#issuecomment-304545878

Seanba commented 7 years ago

If you send me your exported tiled2unity.xml file I can check that out quickly as a start. Thanks.

Seanba commented 7 years ago

Lacking additional information I will close this issue for now. Feel free to re-open if you think there is a bug here that I can reproduce.

indspenceable commented 6 years ago

Hi -

I'm running into the same issue here. I've got a tile that is set up correctly for collisions, but it always ends up only having collisions on the Default layer (it does get a Collision_Default child game object).

I've set the Type on the tile correctly, so when I just place the tile on a normal tile layer, the collisions work as expected; also if I make a rectangular object, it works as expected. When I try to add that tile with a TileObject, even if I add set the Type on the tileobject itself, and I use a tile that has an object w/ a set type, it always only collides on the default layer.

Hope that helps diagnose it! Thank you for your great tool, it's very helpful :)

indspenceable commented 6 years ago

Also - I've looked through my .tiled2unity.xml and it looks like the layer is already Default at that point (see https://gist.github.com/indspenceable/d69503a1e1f6e68a927dfbd937e55ca2) so that leads me to believe that maybe I'm missing a layer setting somewhere? If so it might be intuitive to make that more in line with how you set the collision layer for other objects.... but just speculating here.

Seanba commented 6 years ago

Hi Daniel, do you have a small example I can try to export? You can find my email address from my blog: www.seanba.com

I'll need the TMX file and any tileset data (TSX and textures). Thanks.

indspenceable commented 6 years ago

Hey - I sent an email with an example a few days ago. Let me know if you didn't receive it!

indspenceable commented 6 years ago

Welp, it looks like I got mixed up - using the "unity:layer" does indeed set the layer correctly. Working as intended, this issue should be closed. Thank you!!

Seanba commented 6 years ago

I did a bit of work on this for Tiled2Unity 1.0.13.2, just released now, which does a better job of collecting like-colliders and putting them in a layer appropriately named.