Code: Select all
playerShape = new btCapsuleShape(0.25, 1);
btTransform startTransform;
startTransform.setIdentity ();
startTransform.setOrigin (btVector3(0, 10, 0));
ghostObject= new btPairCachingGhostObject();
ghostObject->setWorldTransform(startTransform);
ghostObject->setCollisionShape(playerShape);
ghostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
controller = new btKinematicCharacterController(ghostObject,playerShape,1);
controller->setGravity(-physics.getWorld()->getGravity().y());
physics.getWorld()->addCollisionObject(ghostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
physics.getWorld()->addAction(controller);
Code: Select all
broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
Now the issue lies in the player stepping down on places where they should fall (heights higher than the step height). Another issue is that it sinks through the floor at certain points (this floor is not created in blender, but rather created before as a plane 100 by 100). The third and really the biggest issue is that it doesn't always step up. This is observed in both imported and non-imported objects, though it is more visible in imported objects (however this could be an ocular error as the non-imported objects are currently invisible). It fails to step up and bumps against the wall of the object.
The way I move the controller is through
Code: Select all
controller->setWalkDirection(btVector3(right, 0, forward));
Code: Select all
controller->jump();
Code: Select all
btTransform trans;
trans = controller->getGhostObject()->getWorldTransform();