Kinematic character controllers always fall too fast

Andrew McDonald
Posts: 4
Joined: Tue Aug 31, 2010 12:12 pm

Kinematic character controllers always fall too fast

Post by Andrew McDonald »

I'm playing with btKinematicCharacterController. I noticed their gravity factor is initialised to 3 * 9.8 instead of just, say, 9.8 - is that intentional? Seems a strange choice. It also seems they have no relationship with world gravity - shouldn't it just use that?

Anyway, the problem I've run into is that characters always fall too fast, even with their gravity set really low. It looks like this is because in btKinematicCharacterController::stepDown, downVelocity is set to m_stepHeight if it's smaller than that and the character is considered "on the ground". Then when calculating step_drop, it's added to m_currentStepOffset, which has previously been set to m_stepHeight in stepUp. The result is a doubling of step height on the way down.

My character is starting in the air, but m_wasOnGround ends up true because both m_verticalVelocity and m_verticalOffset start at 0. Are we supposed to initialise these to something else in these situations? Is this just one of the "outstanding issues" mentioned in the user manual?
SteveSegreto
Posts: 32
Joined: Sun Sep 12, 2010 10:25 am

Re: Kinematic character controllers always fall too fast

Post by SteveSegreto »

Which version of Bullet are you using? I'm using 2.76 and this is how the stepDown function looks:

void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld, btScalar dt)
00352 {
00353 btTransform start, end;
00354
00355 // phase 3: down
00356 btVector3 step_drop = getUpAxisDirections()[m_upAxis] * m_currentStepOffset;
00357 btVector3 gravity_drop = getUpAxisDirections()[m_upAxis] * m_stepHeight;
00358 m_targetPosition -= (step_drop + gravity_drop);

I couldn't find any mention of 3 * 9.81f anywhere in the kinematic controller. Anyway, I had a similar type of problem when I started using the kinematic controller, I noticed that the character fell too slow and that changing gravity in the dynamics world or on the rigid bodies didn't change anything.

The kinematic controller seems to move like a chess piece. First it is lifted up by m_stepHeight, then moved along its walk direction vector and then placed back down (again by m_stepHeight).

There is a member variable called m_fallSpeed, and I believe the multiplication on line 00357 should be by m_fallSpeed and not m_stepHeight. This at least allows you to have the capsule "fall" more or less than it was raised up. For me I could achieve a faster drop by using an m_stepHeight of say 0.35f and a m_fallSpeed of 2.0f
Andrew McDonald
Posts: 4
Joined: Tue Aug 31, 2010 12:12 pm

Re: Kinematic character controllers always fall too fast

Post by Andrew McDonald »

Thanks for the reply; I'm using 2.77 beta. Perhaps these changes since 2.76 aren't quite stable yet.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Kinematic character controllers always fall too fast

Post by Erwin Coumans »

The character controller needs work and customization before it can be used in a game.

If you have some improvements, please share them.
Thanks,
Erwin
Ocelot
Posts: 2
Joined: Sat Nov 11, 2006 1:45 pm

Re: Kinematic character controllers always fall too fast

Post by Ocelot »

Look at http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=5684 I've written how to improve falling.