21-02-2023, 08:49 AM
(This post was last modified: 21-02-2023, 08:53 AM by josemendez.)
(20-02-2023, 09:31 PM)ImpossibleRob Wrote: I have a game where the user can place many objects, potentially thousands, and also use a couple of ropes which should then react to these. The issue is, the ObiUpdater becomes incredibly slow looping through all the obi colliders and updating them. It reaches easily 500ms for only 4000 objects on a high-end pc per frame.
What are recommendations to handle such scenes? Are there optimization tricks or settings I can tweak?
Hi there!
Colliders are Unity components, as such they can't be accessed from any thread other than the main one so their data must be copied to NativeArrays in order to be processed in parallel during the simulation. Updating data for 4000 colliders requires looping trough them in the main thread, there's no way around this.
Having that many colliders active at once is probably a sign that you need to divide your scene into smaller chunks. Depending on how your game is designed, a simple approach could be placing all colliders in a grid and only adding ObiCollider component to those in cells that overlap the solver's bounding box.
This said, 500 ms to loop trough 4000 objects copying just a few bytes worth of data for each seems excessive. I would guess there's something else at play there, probably either death spiraling or some other performance pitfall. Could you share profiler data for this?
kind regards,