using btKinematicCharacterController: falling forever

chutoi
Posts: 16
Joined: Fri Aug 10, 2012 4:21 pm

using btKinematicCharacterController: falling forever

Post by chutoi »

Good afternoon,

I'm learning to use bullet and trying to implement an avatar using btKinematicCharacterController.
My avatar falls through the landscape and just keeps going :(

To debug it I turned off creation of the visible mesh and turned on debugDrawWorld() calls.
I can see the capsule is created and is passing through the static objects that make up the landscape.
You can see the capsule below the landscape:
ScreenCapture.2012.8.24.13.33.20.jpg
The capsule is rendered in red so I added a call to disable deactivation of the object.
This did not improve the result. Any other suggestions?

Is this class supposed to automatically handle collisions with static objects?
If not, are there any examples/documentation of how to do it yourself?

Is the capsule for the ghost object in the character demo the recommended way to use this code?
Should we replace the capsule with our own more complex shape (btBvhTriangleMeshShape in my case)?

Here's the initialization code for the avatar/character:

Code: Select all

      btTransform startTransform;
      startTransform.setIdentity();
      startTransform.setOrigin( btVector3( 0.0f, 0.0f, 0.0f ) );

      m_ghostObject = new btPairCachingGhostObject();
      m_ghostObject->setWorldTransform( startTransform );
      m_ghostObject->setActivationState( DISABLE_DEACTIVATION );

      btVector3 worldMin( -1000, -200, -1000 );
      btVector3 worldMax( 1000, 200, 1000 );
      m_overlappingPairCache = new btAxisSweep3( worldMin, worldMax );
      m_overlappingPairCache->getOverlappingPairCache()->setInternalGhostPairCallback( new btGhostPairCallback() );

      btConvexShape* capsule = new btCapsuleShape( characterWidth, characterHeight );

      m_ghostObject->setCollisionShape( capsule );
      m_ghostObject->setCollisionFlags( btCollisionObject::CF_CHARACTER_OBJECT );

      btScalar stepHeight = btScalar( 0.35f );
      m_character = new btKinematicCharacterController( m_ghostObject, capsule, stepHeight );

      m_character->setJumpSpeed( 10.0f );
      m_character->setFallSpeed( 20.0f );
      m_character->setMaxSlope( 1.5f );
      m_character->setGravity( 1.0f );
You do not have the required permissions to view the files attached to this post.
chutoi
Posts: 16
Joined: Fri Aug 10, 2012 4:21 pm

Re: using btKinematicCharacterController: falling forever

Post by chutoi »

Checking the collision manifolds I see that I'm detecting collisions (see log below).
It's just not doing anything about them. Isn't the character controller supposed to handle collisions with terrain for you?

Code: Select all

16:59:38: Biped::UpdateCamera() Collisions: 0
16:59:38: Biped::UpdateCamera() Collisions: 0
16:59:38: Biped::UpdateCamera() Collisions: 2
16:59:39: Biped::UpdateCamera() Collisions: 4
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: -0.0103957 32.6627 0.0147214
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: 0.00381184 32.6625 0.00176373
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: 0.00111519 32.6625 0.00533667
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: 0.0103957 32.6627 -0.0147214
16:59:39: Biped::UpdateCamera() Collisions: 4
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: 0.130498 33.3176 -0.00213526
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: 0.00381184 30.8291 0.00176373
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: 0.130636 33.3175 -0.00323398
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: 0.00111519 30.8291 0.00533667
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: -0.130579 33.3176 0.00292636
16:59:39: Biped::UpdateCamera() getPositionWorldOnA: -0.130511 33.3176 0.00215125
16:59:39: Biped::UpdateCamera() Collisions: 4
16:59:39: Biped::UpdateCamera() Collisions: 4
16:59:39: Biped::UpdateCamera() Collisions: 4
16:59:39: Biped::UpdateCamera() Collisions: 3
16:59:39: Biped::UpdateCamera() Collisions: 2
16:59:39: Biped::UpdateCamera() Collisions: 1
16:59:39: Biped::UpdateCamera() Collisions: 0