Box2D by default does its best to prevent tunneling, computing the discrete simulation using a continuous collision detection. Unfortunately, for a performance-related reason, this kind of collision detection is applied only on dynamic bodies versus static bodies. This means we can produce tunneling between two dynamic bodies.
Look at the following script:
package { import flash.display.Sprite; import flash.events.MouseEvent; import Box2D.Dynamics.*; import Box2D.Collision.*; import Box2D.Collision.Shapes.*; import Box2D.Common.Math.*; public class Main extends Sprite { private var world:b2World; private var worldScale:Number=30; public function Main() { world=new b2World(new b2Vec2(0,5),true); debugDraw(); var bodyDef:b2BodyDef=new b2BodyDef(); bodyDef.position.Set(320/worldScale, 470/worldScale); var polygonShape:b2PolygonShape= new b2PolygonShape(); polygonShape.SetAsBox(320/worldScale, ...