(03-10-2018, 08:49 AM)josemendez Wrote: Hi rosedev,
1.- Those spikes are probably due to FixedUpdate() being called more than once those frames.
This is the way physics work in Unity (and in any fixed-tilmestep engine): time is accumulated in the regular render update loop (deltaTime), then each frame evenly sized (fixedDeltaTime) chunks are processed. If enough time to require a second (or third, or fourth) physics update in a frame has been accumulated, then that particular frame will take more time to process. Note that this can sometimes lead to a phenomenon called "death spiral" in which the game enters a downwards performance spiral due to too much accumulated physics time, and that Unity offers a way of determining the maximum amount of times FixedUpdate is called in a frame (max fixed timestep) in order to alleviate this. See:
https://docs.unity3d.com/Manual/class-TimeManager.html
2.- Obi only considers colliders that are very close to particles, as it internally uses a hierarchical spatial partitioning structure to store them and determine those that might collide with particles in the particle grid. Static colliders away from particles have zero cost (they aren't even updated). Dynamic colliders away from particles are slightly more expensive as the internal structure has to be updated, but still their cost is near minimal as they generate no contacts. Only colliders actually in contact will particles affect performance.
Anything you do to enable/disable colliders at runtime will most likely only worsen performance.
Thank you for the help! I have one more issue with Obi colliders. Unity Editor crashes when I'm trying to set negative scale to a GameObject with EdgeCollider2D and ObiCollider2D attached. The same happens when I'm trying to set negative scale (x=-1) to the bucket in the sample scene.
Is there some workaround for this?
Tested with 2018.2.1 and 2018.3 beta