BGE: When applying movement to an object with the Character physics type, use the btKinematicCharacterController's setWalkDirection() instead of moving the physics object ourselves. This reduces issues with tunneling (the character going through other objects).

This commit is contained in:
Mitchell Stokes
2012-10-07 19:10:03 +00:00
parent c80c4c896a
commit 9fcb7cd520
2 changed files with 15 additions and 6 deletions

View File

@@ -895,18 +895,22 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc
return;
}
// btRigidBody* body = GetRigidBody(); // not used anymore
btVector3 dloc(dlocX,dlocY,dlocZ);
btTransform xform = m_object->getWorldTransform();
if (local)
{
dloc = xform.getBasis()*dloc;
}
xform.setOrigin(xform.getOrigin() + dloc);
SetCenterOfMassTransform(xform);
if (m_characterController)
{
m_characterController->setWalkDirection(dloc/GetPhysicsEnvironment()->getNumTimeSubSteps());
}
else
{
xform.setOrigin(xform.getOrigin() + dloc);
SetCenterOfMassTransform(xform);
}
}
}