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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -115,6 +115,11 @@ protected:
|
||||
virtual void setLinearAirDamping(float damping);
|
||||
virtual void setUseEpa(bool epa);
|
||||
|
||||
int getNumTimeSubSteps()
|
||||
{
|
||||
return m_numTimeSubSteps;
|
||||
}
|
||||
|
||||
virtual void beginFrame();
|
||||
virtual void endFrame() {}
|
||||
/// Perform an integration step of duration 'timeStep'.
|
||||
|
||||
Reference in New Issue
Block a user