I'm trying to use Bullet physic engine to create a 3D world.
I've got my character with a Capsule shape on his body and my ground his made of some static blocs stick together, here is a schema to illustrate my words:
The problem is present when my character run from one block to another: Bullet detect a collision and my character start to jump a little bit on y-axis.
How can I avoid the problem?
What I did to overcome this issue is the following:
Instead of have the capsule slide on the ground, I had a dynamic capsule ride on top of a spring. I implemented the spring as several ray casts originating from bottom of the capsule. The length of the spring was like half a meter or less and it would pull and push the capsule to and from the ground. The grip/pull is important so the character wouldn't jump unexpectedly. The springs stiffness controls how much bobbing you have.
This had the following effects
I had to play around a lot with the stiffness of the spring, the length of the spring, the length of the grip etc. but in the end I was very happy about how simple yet well this worked.
Your problem caller "Internal Edge Collision". I just found the solution few our hour ago. If you are using btHeightfieldTerrainShapefor your world then you must use btBvhTriangleMeshShape to slove this problem.
Here is the answer.
Add this callback:
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp,const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
btAdjustInternalEdgeContacts(cp,colObj1,colObj0, partId1,index1);
return true;
}
extern ContactAddedCallback gContactAddedCallback;
Afterwards create the btBvhTriangleMeshShape
and add this code where pGround
is your btBvhTriangleMeshShape
:
// Enable custom material callback
pGround->setCollisionFlags(pGround->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
btTriangleInfoMap* triangleInfoMap = new btTriangleInfoMap();
btGenerateInternalEdgeInfo(pGroundShape, triangleInfoMap);
Or you can open the InternalEdgeDemo
example in Bullet
to see how to implement it in detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With