It seems after moving in a direction then stopping, the controller will move randomly on some axes by small amounts (0.0001) per frame. The effect is even worse with a capsule shape.
I came across someone else having a similar issue via google: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=80705
He points out that the "recoverFromPenetration" function is the culprit.
Does anyone know of a solution or know of a better kinematic based character controller that I could make use of. I'd like to avoid writing my own just because I'm not an expert and would rather learn from mature code than trail and error.
Edit: I've found that, indeed, recoverFromPenetration is causing the issue. If you take a look at where it's used in preStep:
Code: Select all
void btKinematicCharacterController::preStep ( btCollisionWorld* collisionWorld)
{
int numPenetrationLoops = 0;
m_touchingContact = false;
while (recoverFromPenetration (collisionWorld))
{
numPenetrationLoops++;
m_touchingContact = true;
if (numPenetrationLoops > 4)
{
//printf("character could not recover from penetration = %d\n", numPenetrationLoops);
break;
}
}
m_currentPosition = m_ghostObject->getWorldTransform().getOrigin();
m_targetPosition = m_currentPosition;
// printf("m_targetPosition=%f,%f,%f\n",m_targetPosition[0],m_targetPosition[1],m_targetPosition[2]);
}
Edit2: I'd also like to point out that I'm testing with a cylindrical shape for the controller and I've tested it against a simple static rigidbody with a cube shape as the ground. The problem does not seem to happen on the cube shape at all, even on the edges. The issue does occur when moving to a static rigid body with a BvhTriangleMeshShape shape. Interesting.