I'm trying to use the btKinematicCharacterController for my game but I have a problem related to time synchronization.
I tried a lot of things but I can't make it work properly.
Here is the pertinent code:
Very simple bullet initialisation
Code: Select all
//Bullet initialisation.
broadphase = new btAxisSweep3(btVector3(-5000,-5000,-5000), btVector3(5000,5000,5000), 1024);
btOverlappingPairCallback* m_ghostPairCallback = new btGhostPairCallback();
broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(m_ghostPairCallback);
collision_configuration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collision_configuration);
sequential_impulse_constraint_solver = new btSequentialImpulseConstraintSolver();
world = new btDiscreteDynamicsWorld(dispatcher, broadphase, sequential_impulse_constraint_solver, collision_configuration);
world->setGravity(btVector3(0,-20.0f,0));
Code: Select all
btClock timer;
timer.reset();
while(true)
{
if(timer.getTimeMilliseconds() > 16) {
world->stepSimulation((float)timer.getTimeMicroseconds()*0.000001f, 10);
timer.reset();
}
sf::Sleep(0.001f);
}
Code: Select all
character_controller->setWalkDirection(
btVector3(
Ogre::Math::Cos( angle ) * speed * 2.0f * p_time,
0,
Ogre::Math::Sin( angle ) * speed * 2.0f * p_time));
As it's a networked application, I really need to synchronize object on the time.
Thanks to read this.
(English isn't my native language)