Kinematic Character isn't interacting with dynamic objects

PgrAm
Posts: 12
Joined: Sun Apr 15, 2012 3:34 pm

Kinematic Character isn't interacting with dynamic objects

Post by PgrAm »

according to here: http://code.google.com/p/bullet/source/detail?r=1457 bullet should support collisions between btKinematicCharacterController and dynamic objects however when my character comes into contact with dynamic objects it does one of two things:

1. goes right through the object
2. walks over the object

it doesn't push objects as I would expect it to

this is how I set it up:

Code: Select all

	
btTransform startTransform;
	startTransform.setIdentity ();
	startTransform.setOrigin (btVector3(0, 0, 0));

	btConvexShape* capsule = new btCapsuleShape(width, height);

	m_ghostObject = new btPairCachingGhostObject();
	m_ghostObject->setWorldTransform(startTransform);
	broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
	m_ghostObject->setCollisionShape(capsule);
	m_ghostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);

	charCon = new btKinematicCharacterController (m_ghostObject, capsule, stepheight);

	charCon->setGravity(-dynamicsWorld->getGravity().getY());

	dynamicsWorld->addCollisionObject(m_ghostObject, btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::AllFilter);
	dynamicsWorld->addAction(charCon);
is there anything I'm missing that might cause this behavior?
mlan
Posts: 2
Joined: Sat Jan 12, 2013 5:18 am

Re: Kinematic Character isn't interacting with dynamic objec

Post by mlan »

Make sure you have:

overlappingPairCache->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());

right after you set up your dynamics world. For me i have it in my setupPhysics() and it looks like:

Code: Select all

dynamicsWorld =
    new btDiscreteDynamicsWorld(
                                dispatcher,
                                overlappingPairCache,
                                solver,
                                collisionConfiguration);
    
	dynamicsWorld->setGravity(btVector3(0,-9.81,0));
    
    overlappingPairCache->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
Should do the trick.