btKinematicCharacterController and interpolation

LEgregius
Posts: 26
Joined: Tue Oct 14, 2008 1:34 am

btKinematicCharacterController and interpolation

Post by LEgregius »

When using setVelocityForTimeInterval, you give a velocity vector and a time, which conceptually works fine, but when running the physics engine using a fixed time step on the physics and variable timestep externally, bullet will interpolate the rigid bodies. It does not, however, interpolate the character controller, so the motion of the character is jerky and appears to speed up and slow down if framerate doesn't sync up nicely with the fixed time step.

If I instead just use setWalkDirection and give it an absolute displacement, that works better, except that it won't work if the framerate of the application is higher than the fixed time step framerate (i.e. smaller time deltas) because if setWalkDirection is set every frame, some of those calls will be ignored because the physics engine won't step. I wrote code to figure out if the physics engine actually stepped the last frame, and if not, just accumulate the displacement from the last frame, but that seems more like a hack than anything else.

I could see changing setWalkDirection to accumulate and clear when the motion model is updated, which is a very small fix that I would think would work for anyone using the system.

As for the interpolation in the first case, I can't see any way to do it because I don't have access to the difference between the accumulated simulated time and the actual local time. Otherwise, I would just copy the code from synchronizeSingleMotionState.
Zeitgeist
Posts: 1
Joined: Mon Jun 20, 2011 6:04 pm

Re: btKinematicCharacterController and interpolation

Post by Zeitgeist »

Sorry for digging up an old thread.

I've been running into the same problem and one would think that this is a major issue for anyone in need of a working kinematic character controller.

How are other people dealing with the issue and are there any existing, proper (non-hack) solutions for it?