However, the characters slide when the slope of the terrain isn't zero. Meaning, when you walk down a gentle hill, gravity still takes place and pulls the character down the gentle hill. I'd like to change this so the slopes don't cause the character to slide, rather just stick to the terrain.
What properties should I look at and try?
I'm using a capsule shape and a btKinematicController and Action for my characters.
I'm using a btHeightfield shape and btRigidBody.
I've attempted to set the Friction of both to one, but it seems to be ineffective.
[SOLVED]
The issue deals with the calculation of the vertical velocity. If you want your character to stick onto slopes and what not (as in, not slide down gradual slopes) then subclass the KinematicController, override the playerStep method, and add the following
Code: Select all
if (!(m_wasOnGround && m_walkDirection.isZero()))
{
m_verticalVelocity -= m_gravity * dt;
if(m_verticalVelocity > 0.0 && m_verticalVelocity > m_jumpSpeed)
{
m_verticalVelocity = m_jumpSpeed;
}
if(m_verticalVelocity < 0.0 && btFabs(m_verticalVelocity) > btFabs(m_fallSpeed))
{
m_verticalVelocity = -btFabs(m_fallSpeed);
}
m_verticalOffset = m_verticalVelocity * dt;
}
Note that this code worked for generally every case with my playpen, but it might not be optimal for other solutions. I do not know how this responds to such actions as jumping atop static objects, moving platforms, etc.