I'm trying to use the btKinematicCharacterController, I may end up implementing my own, but I'll probably look to that for some example code, though. The specific issue I'm having, though, is that the sweep test is not detecting the ground. I'm not rendering anything alongside the body, but I've got it to where it prints out the y coordinate of the ghostObject's position every tic. I intentionally put it obnoxiously high for a start point, but it ends up not detecting the ground and passing though it. I also put it a line of code in the btKinematicCharacterController to alert me whenever the sweep test detects a hit, though it never does. The ground object is a rigid body that otherwise works fine, it interacts with some weapons that I added physics to just fine. I'm using the irrlicht engine, and both the ground and the player objects are derived from the scenenode class there. My code is heavily encapsulated, but I'll try to get the function calls in order:
//this is the ground setup
cout<<"setting up physics"<<endl;
collObj = 0;
matrix4 transform = getAbsoluteTransformation();
vector3df rot = transform.getRotationDegrees();
btVector3 trans = btVector3(getAbsolutePosition().X,getAbsolutePosition().Y,getAbsolutePosition().Z);
btQuaternion quat = myGame->EulerXYZtoQuat(rot);
//this function works, i've tested it
myGame->QuaternionToEuler(quat, EulerRotation);//mygame just contains all of my "global" attributes, including the dynamicsworld and others.
vector3df rotation = vector3df(EulerRotation, EulerRotation, EulerRotation);
// Give it a default MotionState
btDefaultMotionState *MotionState = new btDefaultMotionState(bulletTransform);
// Create the shape
aabbox3df box = getMesh()->getBoundingBox();
btVector3 HalfExtents( getScale().X*(box.MaxEdge.X - box.MinEdge.X), getScale().Y*(box.MaxEdge.Y - box.MinEdge.Y), getScale().Z*(box.MaxEdge.Z - box.MinEdge.Z));
btCollisionShape *Shape = new btBoxShape(HalfExtents*.5f);
// Add mass
collObj = new btRigidBody(mass, MotionState, Shape, LocalInertia);
// Store a pointer to the irrlicht node so we can update it later
// Add it to the world
kinematic = false;
//this is the character controller
btCollisionShape* shape = new btCapsuleShape(.1f,2.f);
body= new btPairCachingGhostObject();
controller = new btKinematicCharacterController(body,(btConvexShape*)shape, .25f,1);
}//end of setupPhysics
I'll post more if necessary, but I could really use some help. I'm wondering if I'm missing a function call or something.
Edit: a raytest works, why wouldn't a sweep test?
Edit 2: Ok, so all I had to do was make the ground a static object and the collision detected. It still doesn't stop falling, however. Why would this be?