javascriptbox2dgame-physicsphysics-enginebox2dweb

Box2d bodies unstable and does not come to rest


I was trying to experiment with box2d as a PoC for a game project, well i managed to create the world and bodies and default DebugDraw in place. Have been playing with restitution, density and friction but could not get the desired behavior and the bodies are unstable and keeps on flickering/bouncing that too very fast.


SEE the running code here: http://jsbin.com/qoceranu/1/edit


I have tried following things:

As i am new to it, hence i believe i could be doing something fundamentally wrong. What do you think is the problem? Bodies never come to rest, neither its the natural behavior.

Thanks in advance.


Solution

  • The step length is waaay too long. Try changing this line:

    physics.renderingEngine.init(~~(1000 / 60), 10, 10);
    

    to:

    physics.renderingEngine.init( 1 / 60 , 10, 10);