Bullet physics, friction?

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Bullet physics, friction?

Post by hendu »

Since there are a lot of Bullet users here too, I'll ask for your opinions as well. This was also posted at the Bullet forum some days ago, no replies so far though.

I'm not using any of the irrlicht-bullet wrappers. You might recognize the screenshot ;)


I have some terrain fed to bullet as triangles, and I drop a character on a hill there.
The character is represented as a capsule. His mass was originally 80kg, but setting it to 1kg had no effect.
I'm on bullet 2.77.

Collisions work, but I have an issue with friction.

When I drop the character there, he slides down the hill! It's like the hill was made of
ice, and he had well oiled boots.

Image

So I then tried setting the friction, first for the ground only and then for both. No matter
what values I used, be it 0.5, 1 or 1000, ground only or both, it had no effect (bug?).

With friction useless, I read around, and it was said to use dampening to simulate friction.
However, linear dampening caused him to fall in slow motion (=useless), and to get proper
friction I had to use really high values for angular dampening, 0.9 to 1.
Of course, with such high values, I can't move him myself without huge forces (on the
order of 10k).


Please enlighten a bullet newbie, how can I get proper friction /and/ be able to move my
chars?



PS: I did notice that if I set linear velocity, I can get him to move how I want, but
setting that would ignore all forces from collisions, am I right?
macron12388
Posts: 126
Joined: Wed Sep 29, 2010 8:23 pm

Post by macron12388 »

I don't have an enormous amount of experience, but I'll try to help.

You would have to create another system which simulates things that happen in real life physics.

i.e. In real life we are not "capsules" when when we move around.

Your attempt to use simple capsules to simulate things like shoe friction, leg resistance etc will simply need another layer of simulation.

Thankfully, since "hominid characters" are something quite common in games, bullet already comes with this

Code: Select all

bullet-2.76\src\BulletDynamics\Character
That last directory should contain some helpful files to help you get started.
I've heard complains that the one included in bullet isn't sufficient,so once you get an idea of what's going on in btKinematicCharacterController.cpp/h you should be able to go ahead and customize/optimize however you see fit.
Mikhail9
Posts: 54
Joined: Mon Jun 29, 2009 8:41 am

Post by Mikhail9 »

macron12388 wrote: In real life we are not "capsules" when when we move around.
My suspicion is that your collision capsule has only one contact point with the terrain and as a result bullet is not calculating friction the way you expect. Try using a cube for your collision shape and see if this fixes the problem.

You can enhance that collision shape after you get something working the way you expect. Or just go to the examples macron12388 identified.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Post by hendu »

@macron

There might be 150-300 enemies going on at one point, so to save some processing I think I should be using simple collision models. Proper friction with a simple model would be enough, I don't need vertex-perfect collisions that are in sync with the animation state, for example.

@Mikhail

Boxes in bullet have the serious weakness that they only collide by the corners. Thus at bigger speeds they tend to just go through terrain.
This happens in the bullet demos too, where one can shoot cubes.

I will try other shapes though, thanks for the hint. Maybe a cylinder would act better.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

hendu wrote:@macron

There might be 150-300 enemies going on at one point, so to save some processing I think I should be using simple collision models. Proper friction with a simple model would be enough, I don't need vertex-perfect collisions that are in sync with the animation state, for example.

@Mikhail

Boxes in bullet have the serious weakness that they only collide by the corners. Thus at bigger speeds they tend to just go through terrain.
This happens in the bullet demos too, where one can shoot cubes.

I will try other shapes though, thanks for the hint. Maybe a cylinder would act better.
How are you going to manage 150-300 active enemies with full physics?
Even if you use simple geometry for collision you'll waste lots of CPU resources resulting in a framerate drop
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Post by hendu »

@Radikalizm

Well, I was going to use Bullet obviously ;)

I need them to collide properly with each other, the terrain etc, and have projectiles & explosions cause forces on them.
If I'm clearly doing it wrong, please say so :)


@All

Just documenting it here just in case it helps others.

Using a cylinder, setting friction of both ground and the char to 1, and angular dampening of the char to 0.7, I have fairly good friction.

The char still slides when he should: when the angle is steep enough. Otherwise he stops as he should.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

hendu wrote:@Radikalizm

Well, I was going to use Bullet obviously ;)

I need them to collide properly with each other, the terrain etc, and have projectiles & explosions cause forces on them.
If I'm clearly doing it wrong, please say so :)
Well yes, I know that you are using bullet, but managing hundreds of enemies with full collision detection and without any LOD in the physics system is going to be a performance nightmare
I don't have enough experience with bullet to know if it handles LOD by itself, but I have a feeling that it doesn't
Post Reply