Howto stop bouncing

Rutger Janssen
Posts: 1
Joined: Thu Mar 15, 2007 9:45 pm

Howto stop bouncing

Post by Rutger Janssen »

A quick newbie question, how can I prevent my capsule from bouncing (after falling from a great height)?
Here's the code I use for the capsule:

Code: Select all

	btCollisionShape* shape=new btCylinderShape(btVector3(1,2.5f,1));
	trans.setIdentity();
	trans.setOrigin(btVector3(-14,35,37.3f));
	player_body = new btRigidBody(80,0,shape);
	player_body->setAngularFactor(0.0f);
	player_body->setWorldTransform(trans);
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Hi,

There are several options, here is one that might work for you:

Basically you can override the contact added callback, and set the penetration depth to zero in the contact point. But also move the capsule manually so it doesn't penetrate. Make sure only to set the callback flag for the capsule:

Code: Select all

capsuleRigidBody->setCollisionFlags(staticBody->getCollisionFlags()  | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
Use the contact normal * penetration depth to move out the capsule manually.
For details on overriding the contact added callback, search for ContactAddedCallback in ConcavePhysicsDemo.cpp (ignore parts about friction)

Hope this helps,
Erwin

By the way, someone recently implemented this, so perhaps you get a more detailed answer from him later.
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Post by ola »

I implemented a character capsule recently, but I still have some bouncing. I set the restitution factor of the capsule to zero, and was happy enough with the result of that. For normal walking around and character jumps there is no bounce.

The little bounce that is left when falling of tall things doesn't worry me much as I plan to enable a ragdoll-model of the character instead if it is hit with impulses exceeding a certain limit.

Best regards,
Ola