Smooth first person movement? (adding delta-time)

Problems like this come most likely from the stepping parameters. In your case:

do_physics(co->get_dt(), 1, 1.0 / 60.0);

The first param is the total time delta which should be simulated. Passing the elapsed time since the last call to do_physics is right.

Now Bullet can either simulate this delta time in one go (not recommended), or split it up in smaller substeps of a fixed size, which makes the simulation more smooth (recommended). How many substeps is a tradeof between performance (less substeps are faster) and quality (the more substeps the smoother).

The second param is the maximum number of substeps bullet should do.
The third parameter is the fixed size of each substep bullet.
The remaining time between the last substep and the elapsed time is interpolated by Bullet.

Let’s make an example. Large substeps for easier calculation.

  • elapsed time = 0.43 seconds
  • max num substeps = 10
  • substep size= 0.1 seconds.
    ==> Bullet will do four substeps of 0.1 sec each, and then interpolate the remaining 0.03 seconds.

Idea would be to always have a fixed step size, but since frame rendering and game logic are not that constant we will have a varying step size each frame. Usually the steps are 1/60 sec seconds or longerSo a good choice would be
world->do_physics(dt, 10, 1/200)

Every single substep is 1/180 seconds. A “normal” frame of 1/60 … 1/55 seconds will have three fixed size substeps and a tiny amount of interpolated time. If your frame rate goes down to 1/40 or 1/20 you will have more substeps, up to 10, and some more interpolated time. Don’t overdo it with the maximum number of substeps, since more substep mean less performance, and when your framerate is down anyway you don’t want to make things (much) worse.

After all it’s a bit of playing around with different substep sizes until you find something suitable for your game. don’t forget to keep slower computers in mind, which some of your players might still have. Perhaps a setting for “performance” (high/medium/low) with different max_substep/substep parameters might be reasonable.