I have a moving object for which I defined a collision sphere and 2 cubes with their corresponding bounding boxes. The space between the cubes is very small, the moving object should not be allowed to pass between them. To detect the collisions I’m using a CollisionHandlerPusher, but the moving object manages to pass between the cubes.
I defined another camera on top of the scene and when looking at the collisions I see there are 2 of them at each moment, one with the first cube and another with the second one. I can also see that the moving object is moved rapidly between 2 positions, probably the ones where is pushed by the collided objects.
Is this normal? Is there a fix or a workaround for this?
Cubes are hard, because they have lots of different surfaces, all of which are pushing your sphere in different directions. When you get two cubes with a tiny space between them, you have twelve different faces which all want to push on your sphere. The collision system isn’t always able to resolve which faces are the most important.
It’s best to simplify your collision surfaces to the minimum structures that you actually require to keep your sphere where it belongs. Instead of two cubes, make two walls (two polygons). And make sure there isn’t a gap between the two walls–the polygons should meet precisely at the vertices. Even better, make only one polygon if you can.
Or, use spheres universally instead of cubes. Spheres don’t have the problem that cubes have, because a sphere is itself a well-defined solid, instead of six loosely-coupled polygons.