drleviathan wrote:

You modulate it by actually setting its velocity, and you can set its magnitude to be as long as you like.

I see. So now instead of modify the friction, I calculate the forward direction vector on contact point and set the velocity on it. Below is my code:

**Code:**

btVector3 minDir;//forward direction of closest contact point

float t_speed = core::abs_(m_speed);//m_speed is current track speed (negative means backwards)

for (int j = 0; j < pm->getNumContacts(); j++)

{

btManifoldPoint& point = pm->getContactPoint(j);

point.m_lateralFrictionInitialized = true;

point.m_lateralFrictionDir1.setValue(dir.X, dir.Y, dir.Z);//dir is current forward direction of track object

//point.m_lateralFrictionDir1.normalize(); comment this line because dir is already normalized before in my code

point.m_contactMotion1 = 2;

point.m_combinedFriction = 9;

point.m_combinedRestitution = combinedRestitution;

if (abs_(point.m_distance1) < min_distance)

{

//find closet contact point

min_distance = abs_(point.m_distance1);

btVector3 herizonLeft = point.m_lateralFrictionDir1.cross(

point.m_normalWorldOnB);

//calculate forward direction of contact point

minDir = point.m_normalWorldOnB.cross(herizonLeft);

}

}

//set velocity

if (pm->getNumContacts() > 0)

{

btVector3 vel_new = t_speed * minDir;

bt_rigidbody->setLinearVelocity(vel_new);//rigidbody is track itself

}

Is this the right way to do it?