In my world, x and y are the vectors the player travels across and z is the height vector. The problem I get from this, is that when I create the btKinematicCharacterController's capsule shape, it's facing down the x and y axis, not the x and z. I can manually rotate the ghost object, but it messes up how the character controller see's the ground. I've also tried a combination of the controller's up axis as well as rotating, but that sent the character falling due to gravity in the wrong axis.
Below is the code I am using to set up the character...
Code: Select all
//Ghost Object
transform.setIdentity();
btPairCachingGhostObject* ghostObject = new btPairCachingGhostObject();
broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
ghostObject->setWorldTransform(transform);
//Capsule
btConvexShape* characterShape = new btCapsuleShape(0.5, 1.0);
ghostObject->setCollisionShape(characterShape);
ghostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
ghostObject->setFriction(1.0);
//Character controller
playerController = new btKinematicCharacterController(ghostObject, characterShape, 0.01, 2);
//Add collision object to world
dynamicsWorld->addCollisionObject(ghostObject,
btBroadphaseProxy::CharacterFilter,
btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);
//Add controller to world
dynamicsWorld->addAction(playerController);