I’m working on a first prototype for my game. The game will have a large amount of sprites, so generating colliders by hand is something I’d like to avoid. So I’m letting Unity generate the colliders for me. I’m using PolygonColliders because sprites can be highly irregular, so they add a lot of realism to collisions.
In my testing, the framerate drops to ~30 (from 60, because VSync) when around 50 sprites are on screen. I don’t expect to have this many enemies on screen, but I’d like to make mobile builds if I can get the performance high enough. So: PC builds might be fine at this point, mobile probably not.
Some more info about the setup:
This is my test scene with ~50 enemies (Yep, those are maplestory sprites, used as placeholders):
This is the setup of one of the large guys:
As you can see. it generates a collider with 76 points. It matches the shape quite nicely, but obviously adds a lot of overhead. I’m also switching between colliders based on the current frame, but as far as I can tell from the profiler, that’s not the issue. I’ve also made sure they’re not triggers, since that also adds a lot of overhead (Framerate < 15 with just 10 enemies).
What else can I do to improve performance? is there any way to have Unity generate PolygonColliders with lower detail? Any cheap to run algorithms I could use myself to generate colliders? Is there a way to disable collisions between all monsters? Maybe that’s what’s tanking my framerate.
And a screenshot of the profiler:


