diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2012-10-07 23:10:03 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2012-10-07 23:10:03 +0400 |
commit | 9fcb7cd520dd5b1befcff9115a707a2b4cfa718a (patch) | |
tree | 4747fec7839158b8150189938e7294d386012f81 /source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | |
parent | c80c4c896aedae7c711d10e6f133d3bdca460de3 (diff) |
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).
Diffstat (limited to 'source/gameengine/Physics/Bullet/CcdPhysicsController.cpp')
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 81bf66d9536..240bda811f0 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -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; + + if (m_characterController) + { + m_characterController->setWalkDirection(dloc/GetPhysicsEnvironment()->getNumTimeSubSteps()); } + else + { - xform.setOrigin(xform.getOrigin() + dloc); - SetCenterOfMassTransform(xform); + xform.setOrigin(xform.getOrigin() + dloc); + SetCenterOfMassTransform(xform); + } } } |