I just started working with Bullet, and I'm confused about how I should apply forces to an object. I've basically got the HelloWorld code from the wiki working and I'm trying to make it so that when I press some key, the ball will "jump". I tried following the code given in the tick call back article, but it's not working correctly. The ball falls down as if no force is being exerted.
What's confusing me is that in that article the code in the callback looks like this:
Code: Select all
btCollisionObjectArray objects = world->getCollisionObjectArray();
world->clearForces();
for (int i = 0; i < objects.size(); i++) {
btRigidBody *rigidBody = btRigidBody::upcast(objects[i]);
if (!rigidBody) {
continue;
}
rigidBody->applyGravity();
rigidBody->applyForce(btVector3(0., 20., 0.), btVector3(0., 0., 0.));
}
return;
But even when I comment out the line about applying gravity, the object still falls down. Where is that gravity coming from? What's the correct way of applying a force to an object? If anyone has any links to tutorials or can point me to a Bullet demo that can help I would appreciate it. So far I have found no basic help online other than the wiki and the only Demo that I found to be close uses DynamicCharacterController, which according to the code is now obsolete.