This is my code create CharacterController:
Code: Select all
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(-102.162f, 104.0f, 317.383862f));
mGhostObject = new btPairCachingGhostObject();
mGhostObject->setWorldTransform(startTransform);
Application::getInstancePtr()->getBpInterface()->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
btScalar characterHeight = 1.5f;
btScalar characterWidth = 0.5f;
btConvexShape* capsule = new btCapsuleShape(characterWidth, characterHeight);
mGhostObject->setCollisionShape(capsule);
mGhostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
btScalar stepHeight = btScalar(0.35);
mCharacter = new btKinematicCharacterController(mGhostObject, capsule, stepHeight);
Application::getInstancePtr()->getBulletWorld()->addCollisionObject(mGhostObject, btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);
Application::getInstancePtr()->getBulletWorld()->addAction(mCharacter);