simplification of polygon collider geometry
Hello,
My apologies as this is more of a "how do I?" question then a bug report; I'm not really sure where to ask such questions.
I'm importing a very basic map into Unity which resulted in the geometry of the polygon collider (which are the green lines) seen in the attached image. You'll notice that in the area circled in red that there is a line that is part of the geometry that doesn't quite track the actual perimeter of the tiles; this causes collision problems in-game. On the right side of the image one should notice that the geometry is also quite complicated.
I'd like to know:
- How does address the problem seen in the red circle?
- How can one simplify the geometry in general? My game engine seems to be sensitive to the complex geometry, and it would be really nice to simply have the geometry be solid lines around the perimeter of the imported map (as opposed to all the triangles used in the geometry).
As an FYI, in Tiled I have a collider on each tile that is the exact same size as the tile.
Thanks,
(geometry of polygon collider as seen in the unity editor)
Hi there, @jamesrobb. Sorry for the late reply. For your questions:
- That extra polygon in your red circle looks like a bug. I've had issues before where I had to remove the map prefab from my scene and then add a new one back to fix such issues. This is a bug with Unity prefab instances built through custom asset importers (I've logged the issue with them some time ago). However, if the bad geometry remains after replacing the prefab instance then it is likely a bug on my end. If you send me your project I can take a look.
- The best/fastest way to simplify the geometry is to go into the Project Settings and opt for
Outlinesas theCollision Geometry Type. Note, however, that your collisions will now be outlines instead of "solid" polygons and depending on your game engine may need to be modified for that. For instance, objects that are fully "inside" a collider will not generate a collision.

Thank you very much for the help!
-
Setting the collision geometry type to "Outlines" definitely worked and produced the desired result :)
-
While leaving the collision geometry type as "Polygons" re-importing fixed the issued I had described but another issue still exists. If you reference the two images below you will notice that my player sinks into the floor beneath him as the geometry erroneously slants down to the right. I'm not sure why this is. Any ideas?
Closer View
The thick yellow outline is not does denote the collision geometry, as an FYI, we are interested in the thin green lines.

Zoomed-out View

As much as I dislike bumping I'm bumping this. Any idea what might be causing this or how I could look into it?
Hi there, @jamesrobb. Sorry for the lack of replies. I've been having difficulty finding time during the pandemic.
It would be useful to see what the "real" collision geometry is by disabling the gizmo for the SuperColliderComponent ...

This will help you concentrate no the thin green lines so we can make sure the geometry looks right.
It might be good to send me a copy of your project so I can take a look. My email is [email protected].