hi, friends
i use box2d to create a game . there is a box slowly moving and some balls in the box, but the balls will overlap when the box is moving. how can i solve this problem?
thank you
Need more input... you mean the balls overlap each other? Or the balls overlap the box? Is there a large number of balls stacked vertically? Are the balls free to move around in the box or are they restricted by a lid above? Is the penetration occurring sideways and caused purely by the movement of the box, or is it vertically? Is it only ever happening when the box moves, or does it happen a little all the time but moving the box makes it worse...? Is the box a kinematic body or dynamic? How are you controlling the box to move? Could you show a picture to help us understand what you mean?
Stacking things into a large pile will often cause the bodies at the bottom to penetrate each other. There is very little you can do about that apart from decreasing the time step length or increasing the number of iterations allowed for the Step() call. You may also be able to dynamically adjust the densities of the things at the bottom of the pile to make them more dense, so they are able to push the bodies above them away more, but that might give you other problems.
If you mean that the balls overlap the box, and you are using SetTransform to move the box, try using SetLinearVelocity instead, and don't suddenly increase the velocity from zero, but raise/lower it gradually.