btKinematicCharacterController and sloped terrains

matthew.snyder
Posts: 1
Joined: Wed Jan 05, 2011 6:21 pm

btKinematicCharacterController and sloped terrains

Post by matthew.snyder »

I've been working with a btKinematicCharacterController for the past week and a half or so, trying to get it do perform a simple task: Walk on solid ground. I've met with varying degrees of failure, and have tried a variety of attempts and implementations in order to make this happen. The problem in particular -- correct behavior on sloped terrain -- has persisted throughout the following attempts:
  • Using a btHeightfieldTerrainShape for the terrain mesh
  • Rewriting the triangle winding so that it matches the Ogre terrain I am using
  • Using a btBvhTriangleMeshShape for the terrain mesh
  • Using the OiJE character controller documented here
  • Using the double-capsule character controller documented here
  • Attempting various ratios of friction, damping, step height, capsule size, etc. in order to determine if a ratio/scaling issue is causing the behavior
  • Tweaking various collision flags of the terrain and the character
At the end of the day, the same thing occurs: my character (with camera attached) falls from the sky and lands on the terrain. If the terrain it lands on is flat, movement it completely normal. If at any point the character bumps into sloped terrain of any angle/degree/steepness -- even if it should logically be able to climb it -- instead it begins re-positioning itself over and over again until it has settled on flat ground again. Even if it does manage to reach a resting point on higher terrain, it will simply repeat the above until it has fallen back down from its current height.

Why is this the case? The behavior seems to mimic a bouncing ball on terrain, but I figured the btKinematicCharacterController would behave more like a human being with legs. Once my character reaches a sloped terrain he should climb it, and stay where he is, and not bounce gradually back to flat ground.

I don't have any example code because the behavior is the same regardless of the code, and I'm not up to untangling the bullet code from the OgreBullet code I'm using. I've taken sample code directly from the demos, and everything is initialized properly, and the idiom for my code is the general idiom for creating a character and a terrain: create the terrain, add it to the world; create the ghost object for the character, create the capsule for the character, create the callback for the dynamics world, add the ghost as a collision object to the dynamics world, resetting the ghost objects by using `cleanProxyFromPairs`.

Thanks for your help!
Covenant
Posts: 4
Joined: Wed Dec 22, 2010 2:31 am

Re: btKinematicCharacterController and sloped terrains

Post by Covenant »

I had a problem similar to that. My problem was that when I was applying a very large downward translation when the player was on solid ground for gravity purposes. Specifically when calling setWalkDirection, I was specifying a velocity instead of a translation.
Ripiz
Posts: 47
Joined: Mon Aug 16, 2010 10:43 am

Re: btKinematicCharacterController and sloped terrains

Post by Ripiz »

I had problem where character was falling through sloped terrains. I ended up making own character controller :(