Advertisement Jump to content
Sign in to follow this  

btKinematicCharacterController Not Behaving Correctly

This topic is 766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I've been trying to add in a character controller in my game by using btKinematicCharacterController. I had some working code from another project that used Bullet, so I'm mostly relying off of that because there isn't a whole lot of documentation for btKinematicCharacterController. For some reason whenever I add it into the world with only a static plane as the other collider, it flies off in the negative x-direction and is not effected by gravity. 


Here is the code for creating the physics world:

// Create the necessary components for a bullet physics world
    bullet_broadphase = new btDbvtBroadphase();
    bullet_collision_configuration = new btDefaultCollisionConfiguration();
    bullet_collision_dispatcher = new btCollisionDispatcher(bullet_collision_configuration);
    bullet_constraint_solver = new btSequentialImpulseConstraintSolver();
    // Create the bullet world
    bullet_world = new btDiscreteDynamicsWorld(bullet_collision_dispatcher,
    // Set gravity, by default it is -9.8 m/s in the y direction
    bullet_world->setGravity(btVector3(0.0, -9.8, 0.0));

Here is the code for the creation of my character controller and its ghost body (collision_shape is a capsule with radius 0.5 and height 1.0)

// Create a ghost object
    ghost_body = new btPairCachingGhostObject();
    // Create the character controller
    controller = new btKinematicCharacterController(ghost_body, collision_shape, btScalar(0.1));
    // Only listen to post-physics tick
    event_listener.listenToEvent(EVENT_PHYSICS_POSTUPDATE, EVENT_MEMBER(SPhysicsController::postPhysicsUpdate));

And then my code to add it to the world

// Add the controller's components to the world
    bullet_world->addCollisionObject(ghost_body, btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter);

Does anyone have any ideas as to why this isn't working? When the btKinematicCharacterController isn't attached to the ghost body, it doesnt seem to have any issues. If anyone has any ideas as to why this is happening it would be much appreciated. Thanks.


EDIT: Apparently in a new update character controllers were given their own gravity, so after updating that the character controller behaves correctly, however it not interpolating smoothly. 

Edited by BlueSpud

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!