Kinematic Character jump, problem with fall speed

Please don't post Bullet support questions here, use the above forums instead.
Champi Atomik
Posts: 4
Joined: Tue Dec 01, 2009 8:14 am

Kinematic Character jump, problem with fall speed

Post by Champi Atomik »

Hello everyone,

I'm using Bullet and Ogre3d in a personnal project.

It works well with collision and some other stuffs. As the jump() function is not implemented yet for the kinematic character controller, I did it by myself. But when the character is in the air, its fallspeed is really slow, and it is the same for a box I put in the air to see how fast it fall.

Can someone help me ?

Here is some code, creation of the character :

Code: Select all

btTransform startTransform;
	startTransform.setIdentity ();
	startTransform.setOrigin (btVector3(0.0,100.0,0.0));
	mPlayerGhost = new btPairCachingGhostObject();
	mPlayerGhost->setWorldTransform(startTransform);
	mPhyWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
	mPlayerShape = new btCapsuleShape(mPlayerEntity->getBoundingRadius()/4,mPlayerEntity->getBoundingRadius()/4);
	mPlayerState = new BtOgre::RigidBodyState(mPlayerNode);
	mPlayerGhost->setCollisionShape (mPlayerShape);
	mPlayerGhost->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
	btScalar stepHeight = btScalar(0.25);
	mPlayerController = new btKinematicCharacterController (mPlayerGhost,mPlayerShape,stepHeight);

	mPhyWorld->addCollisionObject(mPlayerGhost,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
	mPhyWorld->addAction(mPlayerController);
Creation of the physic world :

Code: Select all

mBroadphase = new btAxisSweep3(btVector3(-10000,-10000,-10000), btVector3(10000,10000,10000), 1024);
	    mCollisionConfig = new btDefaultCollisionConfiguration();
	    mDispatcher = new btCollisionDispatcher(mCollisionConfig);
	    mSolver = new btSequentialImpulseConstraintSolver();

	    Globals::phyWorld = new btDiscreteDynamicsWorld(mDispatcher, mBroadphase, mSolver, mCollisionConfig);
	    Globals::phyWorld->setGravity(btVector3(0,-9.81,0));
Thanks

Edit : it seems that the problem comes from the kinematic controller. I have a dynamic rigid body, a box, and its fall speed change with the gravity but not the character, that falls very slowly every time
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: Kinematic Character jump, problem with fall speed

Post by pico »

Hi,

kinematic objects don't react to forces. To let your kinematic character controller fall with gravtiy you need to alter the code for

void btKinematicCharacterController::stepDown ( btCollisionWorld* collisionWorld, btScalar dt)
{
....
btVector3 gravity_drop = upAxisDirection[m_upAxis] * m_stepHeight;
...

gravity_drop needs to be changed according to your needs.
dneckels
Posts: 39
Joined: Mon Oct 12, 2009 6:23 pm

Re: Kinematic Character jump, problem with fall speed

Post by dneckels »

I built a hybrid character, half ray tracing (as in bullet), half physics. Physics activates upon contact with a dynamic body, or jump/free fall.

Works well:
http://www.youtube.com/watch?v=Yp6WMqSSvSk
Ray trace mode=green, physics = red.
Lots of damping on the physics side. Also, invIntertialMatrix = 0 to keep object upright.

Attached the source. Not bullet source, but could easily be adapted.
You do not have the required permissions to view the files attached to this post.