Is there a way to put the collision objects from the tile collision editor, all into 1 object layer?

(Tip) #1

Sorry for the amount of questions… I don’t think LibGDX supports the hidden objects in tile collision editor. However, if I could somehow get all the objects from the collisions in my tileset and put them in a seperate object layer, that would work. Is this possible in Tiled?

(Thorbjørn Lindeijer) #2

This is not currently possible, and in fact it’s not possible to make this work 100%, due to limits on the kind of transformations you can apply to objects (a rotated tile collision object can end up getting “sheared” if its tile object is stretched, and there is no way to represent that except by converting the collision object to a polygon).

That said, it could be supported as an export option, which could even go as far as Tiled2Unity in generating a more optimized collision geometry (see this example). What works best here depends a little on your needs.

I assume you need this layer since it would be your collision layer in libgdx? What would be the best representation of it?

1 Like
(Tip) #3

Correct. There’s currently no way in LibGDX to do this. Perhaps I could implement it myself, but I’m not very experienced in Java. Currently I just manually make objects to set collision in a “collision” layer. But my maps are getting bigger and this takes up a lot of time. In LibGDX I just pull all the objects from the collision layer, turn them into rectangles and then check for overlap with character or NPC hitboxes.

(Thorbjørn Lindeijer) #4

So, the only real problem is that you apparently do not have access to the collision objects set on the tiles? Did you open an issue about this at libgdx?

(Tip) #5

I haven’t, but I noticed that other people had already done that. It had been addressed, but it was never implemented. And that was already over 2 years ago, so I doubt it’ll be implemented any time soon. I guess I’ll just have to do it the slow way. Or maybe try implementing it myself if I’m brave enough.

(Thorbjørn Lindeijer) #6

If it wasn’t implemented, what do you mean with it being addressed? Do you have a link to the issue that was opened?

If the project is still actively being developed, this is most definitely an approach to try!

(Tip) #7

Sorry, wrong wording. I meant the developer of LibGDX recognized that people wanted this feature implemented and he replied to the issue, but he never actually did implement it. I will look up the link later.