PolygonCollider2D.SetPath Slow?

Does anyone have any insider Unity knowledge of why this is slow compared to doing the same thing in 3D? As seen in this Issue Tracker item:

Just curious if it’s worth switching my game to 3D physics just because my game relies on this.

Yes it is slow because it has to decompose that outline that can potentially be concave into multiple convex shapes. It’s not something you’d want to be doing very often during game-play. I’m not sure what the equivalent 3D physics is you’re referring to.

I see. In the issue tracker post the guy mentions that it was faster to do virtually the same thing in the 3d physics system (ie. build a 3D mesh that is just a 2D polygon with some Z-depth). I’m not sure if his test was fully valid or not though since I can’t download his test files anymore.

Thanks for the post. My game unfortunately could require this every frame which as you can imagine ends up being a disaster :). Hmmm not sure what else I can do then.

Building a 3D mesh with multiple arbitrary convex shapes is not all that fast. I doubt it could be done faster in a script than what Unity has built-in for the polygon collider. It’s also never been recommended to update 3D mesh colliders every frame, either, since that’s fairly slow as well.

–Eric

Hmm I see. Seems like my whole game idea is pretty much dead then. Would there ever be a possibility of having more strict ways to set the paths? Ones that require the user to use the typical path convention (clockwise and counter-clockwise). I’m assuming that would speed things up since it wouldn’t have to do certain checks, but unfortunately I can’t implement this myself since there’s not much available.