Strange slow movement in Box2D

Strange slow movement in Box2D
0.0 0


I’ve got all set up ok in my project. But I’ve noticed a strange behavior - bodies are moving very very slowly. FPS is 58-60, timestep = 1/30. Maybe I don’t know some kind of magic, that makes bodies move faster? :slight_smile:
If somebody got that issue - please give an advice.

Thanks in advance.


Hi! I think you should use scale factor (“PTM_RATIO”)… and body size should be 0.1 to 10.


I’m trying to learn cocos2dx and box2d so i’m an amateur and I’ve got the same strange behavior.
I’ve tried the 32.f PTM_RATIO , also tried adjusting fixture settings (density, restitution…) but no effect, also tried varying gravity from -10.f to - 100.f but no effect, also tried world->setcontinuousphysics but no effect, my world->step is set to fix 1/60.f and 8 iteration and 3 on position but no effect…

I’ve also look at the box2dtestbed and i’ve seen nothing more that i miss (but certainly i missed something bec. i’ve got a strange slow motion effect no matter what i change, i just don’t know what i missed yet.). Any advice would be appreciated.

Edit: anyhow i got the logic now… my ptm_ratio is not coincide with my viewport and my debugdraw should be scaled also with ptm_ratio.


The reason is in time step. Your app runs on 60 fps but you use time step 1/30 that is why you have the slow motion effect. You need a time step 1/60 to run normal simulation on 60 fps. 1/30 to run normal simulation on 30 fps and etc.

Here is an interesting link about this subject:

Then you should have another problem. Web is running on 30 fps but native on 60 fps. Also on native fps is jumping from 35-60 fps while app is running (box2d is cpu sensitive). I tried several things to solve this issue with one code base (also i try things from Fix your timestep article) and this is solution worked for me very well and it is very easy to implement: (dt is time passed from last update)

Physics.TIME_STEP = 30; //somewhere in Physics class where you store constants for box2d
var accumulator = 0;

//somewhere in update function
if(dt <= Physics.TIME_STEP) 
    this.accumulator += dt;
    //the minimum time step for update is Physics.TIME_STEP to prevent "spiral of death"
    this.accumulator += Physics.TIME_STEP; 

while(this.accumulator >= Physics.TIME_STEP){
    this.accumulator -= Physics.TIME_STEP;

    //destroy joints and bodies here 
    //update joints and bodies here			

Physics.TIME_STEP in this case is the lowest frame rate on platforms you want to launch your app in “standart case” it is web (30 fps) and native (60 fps) that is why in example the Physics.TIME_STEP is 30. (for another example, if the max frame rate on one of platform is 20 than Physics.TIME_STEP should be 20 and etc)