Character friction problems

Character friction problems

Hi, I'm using the character code below to create my rigidBody, and I notice in the character demo, the friction for the world and the character is never set. If I don't set the friction for my character, it slides infinitely in the direction I move. How could this be? If I do set the friction for the character, he stops somewhat accurately, but seems to have a really hard time walking up even the slightest slopes. Maybe someone can enlighten me?

hkpCharacterRigidBodyCinfo info;
info.m_mass = 100.0f;
info.m_shape = mStandShape;
info.m_maxForce = 1000.0f;
info.m_up.set( 0.0f, 1.0f, 0.0f );
info.m_position.set( 0.0f, 20.0f, 1.0f );
info.m_friction = (10.0f);
info.m_maxSlope = mOptions.mMaxSlope;
info.m_supportDistance = mOptions.mSupportDistance;
info.m_hardSupportDistance = mOptions.mHardSupportDistance;
info.m_allowedPenetrationDepth = mOptions.mAllowedPenetrationDepth;
mCharRigidBody = new hkpCharacterRigidBody( info );

// Create the Character state machine and context
hkpCharacterState* state;
hkpCharacterStateManager* manager = new hkpCharacterStateManager();
state = new hkpCharacterStateOnGround();
hkpCharacterStateOnGround* myState = static_cast<hkpCharacterStateOnGround*>(state);
myState->setSpeed( 10.0f );
myState->setGain( 1.0f );
manager->registerState( state, HK_CHARACTER_ON_GROUND);
state = new hkpCharacterStateInAir();
manager->registerState( state, HK_CHARACTER_IN_AIR);
state = new hkpCharacterStateJumping();
manager->registerState( state, HK_CHARACTER_JUMPING);
state = new hkpCharacterStateClimbing();
manager->registerState( state, HK_CHARACTER_CLIMBING);
mCharContext = new hkpCharacterContext( manager, HK_CHARACTER_ON_GROUND );
// Set character type

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Havok - Josh S.'s picture

Hi Drwbns,

I don't think the friction is what you want to use to fix the sliding problem that you had. Friction for the character controller doesn't describe the way the the character ambulates (ie. traction), it's used when the character collides with objects like a table or a door frame, and determines how much this slows him down. The way a character walks around is governed primarily by the player input and the character state - it has little to do with physical concepts like force and friction. Take a look at hkpCharacterStateOnGround::update when the character is supposed to be stopping after being in motion. It should be a simple calculation based on the position of the analog stick (input UD and LR) and the character's walk speed. Any sliding you find should show up in there.


Josh S. Havok Developer Support Engineer

Login to leave a comment.