Collision interpenetration and object getting stuck

I am having what is probably a newbie problem, but for the life of me, I can’t find a decent solution to it. In short: my rigid bodies collide, but sometimes, they interpenetrate and stay stuck.

I am looking for a solution that would either
1- stop the interpenetration from even happening
2- or at least eject the bodies to ‘unstuck’ the collision.

By making the physics fixed step 0.01 instead of the default 0.02, I can avoid some of the interpenetration. However, that hardly sound like the proper way to fix this problem.

Here is a screen shot of the bodies colliding

alt text

To give more information that could be relevant:

  • There is no gravity

  • All the objects have rigid bodies

  • Their sizes are 3.5 x 6.8 and they are moving at 8 to 50 m/s

  • Each object has a conpounded collider made up of 3 box colliders

  • If I change the fixed step to 0.01 there is a lot less more interpenetration (as I mentioned). Other physics settings do not seem to have any effect

  • The object is moved by setting its velocity in the FixedUpdate function with rigidbody.velocity = XYZ until there is a collision, then there is no more processing done in FixedUpdate at all. I detect the collision with OnCollisionEnter and set a flag.

  • I haven’t set any collision material, but I can’t see that being a factor?

Update

As suggested I have tried changing the materials and the mass, but that didn’t give any change in behaviour. I also tried making the rigid body ‘Continuous’ and ‘Continuous Dynamic’, but that didn’t change anything

I also tried reducing the size of everything by a factor of 10, which didn’t change anything either.

Solved

Thanks to everyone who helped me with the issue.

There were a few factors in play. First, there was the scale. What I did to figure this one is create an empty scene and put 2 cubes in there. I varied the size and position of the cubes (from 68x35 to 0.65x0.35 for size and the position by factors or 10 as well) and attached a script to move them, with variation in speed by factors or 10 as well. So all else being equal (same size on the screen and time to cross it), the size of the objects elected a different response to collision: big object got interpenetration, small ones none. I am not familiar enough with Unity to explain the cause of that, but it is reproductible.

A possible second factor was the shape of my colliders and how it may be possible that they screwed up the ejecting part. The colliders I had were not overlapping, so I simplified them to 2 boxes in the shape of a cross.

Finally I was setting the position of the objects manually in FixedUpdate and that caused some problems with interpenetration at lower scale (at higher scale, it didn’t appear to matter). I changed that to work with the body velocity and it helped.

Curious issue.
For a start, what you seem to have is a scale issue.

Basically, what you need to do is scale all your game objects to create proper size - weight relations in the physics system.

For example, for an ideal approach, you should use small colliders (order of size 0.01) with very light objects (rigidbody mass 0.01)

On the opposite, large objects (sizes of 1 and above), need their real-to-life weights setup for their rigidbodies.

Additionally, the collision material can really make a difference, especially regarding friction and bounciness, so you could just try this as first approach!