Unity small rigidbodies not registering collisions well

Hi, in Unity 2D, I have set up some rigidbodies in such a way where I have a sealed jar, and a bunch of small water particles in that jar.

If the jar collides with an object at a velocity of high magnitude, the particles clip out of the jar.

Every rigidbody2D, including the jar never sleeps, extrapolates, and has continuous collision detection.

Is there something I can do to improve the quality of the collisions and ensure that the particles won’t clip out of the jar?

You can try increasing Velocity and Position Iterations at Project Settings>Physics2D

And you can try lowering physics timestep ( to 0.01 or 0.005) to make it update more frequently which is at Project Settings>Time>Fixed Timestep.

Continuous collision detection is absolutely solid, especially in the scenario you’re showing above. It sounds very much like maybe you causing an issue by modifying the Transform or modifying the colliders directly but without further information I could easily be wrong about that.

Note that you shouldn’t need to increases the frequency of the time-step for this, that’s a super drastic thing to do and isn’t required. Continuous solves this just fine.

Looking at the screenshot though, I can see those circles are overlapping themselves (!) so that’s absolutely not using continuous collision detection there so something else is causing overlaps.

Some other notes:

  • Continuous doesn’t work with triggers
  • Continuous only works with Rigidbody2D with a Dynamic body-type
  • Don’t modify the collider properties at runtime
  • Don’t modify the Transform properties at runtime
  • Interpolation/Extrapolation is for Transforms, it has absolutely nothing to do with the physics simulation.
  • Ensure you’ve not modified the global physics settings unless you know what they do. Try resetting to default as a test for instance

If you can share a small project then I’d be happy to take a look at it for you.

Hope that helps.