I'm having problems programming a fast moving character in my game. It penetrates walls, sometimes going through them, as it increases speed. I have read other topics such like this one that talk about bullets or similar fast moving objects, those being always Rigid Bodies (if i understood correctly). I tried to apply the same method for my character, the result being unnoticeable if there is any.
Just for reference, almost every object in my world is a btBoxShape, static, rigid or kinematic. The collision world is initialized this way:
Code: Select all
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
m_overlappingPairCache = new btDbvtBroadphase();
m_constraintSolver = new btSequentialImpulseConstraintSolver;
colWorld = new btDiscreteDynamicsWorld(dispatcher,m_overlappingPairCache,m_constraintSolver,collisionConfiguration);
The character is a capsule, and I initialized it this way:
Code: Select all
btTransform startTransform;
startTransform.setIdentity ();
D3DXVECTOR3 plPos = player.getLocation().getPosition();
startTransform.setOrigin (btVector3(plPos.x, plPos.y, plPos.z));
m_ghostObject = new btPairCachingGhostObject();
m_ghostObject->setWorldTransform(startTransform);
m_overlappingPairCache->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
btScalar characterHeight = 0.7f;
btScalar characterWidth = 0.5f;
btConvexShape* capsule = new btCapsuleShape(characterWidth,characterHeight);
m_ghostObject->setCollisionShape (capsule);
m_ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
m_ghostObject->setActivationState(DISABLE_DEACTIVATION);
m_ghostObject->setCcdMotionThreshold(0.09f);
m_ghostObject->setCcdSweptSphereRadius(0.9f);
btScalar stepHeight = btScalar(0.005);
m_character = new btKinematicCharacterController (m_ghostObject,capsule,stepHeight);
colWorld->addCollisionObject(m_ghostObject,COL_ENTITIES, COL_WALLS|COL_ENTITIES|COL_POW_UPS);
colWorld->addAction(m_character);
Thank you in advance,
nokto.-