Getting proper friction?

lhaw
Posts: 6
Joined: Tue Dec 28, 2010 9:04 am

Getting proper friction?

Post by lhaw »

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?
GameOn
Posts: 35
Joined: Mon Dec 27, 2010 10:46 pm

Re: Getting proper friction?

Post by GameOn »

His mass was originally 80kg, but setting it to 1kg had no effect.
Strange, it should have important effect mainly on you're character accelerations.

I'm not familiar at all with bullet, so please ignore my comment if you want.
But I am not new to your issue. Since your case is pretty simple, I would simply suggest you to apply forces to your character to simulate friction. Apply these forces when your player isn't purposely moving of course (when the player isn't pressing movement keys).

Thus, when the character hit the ground and start sliding down, apply a force in the opposite direction of the velocity. Reduce the strength of this force as the velocity of the character reduce and remove the force when the player's velocity reach near 0 at which point bullet should just put your object in sleep mode until the user move the character or until something collide with him giving him a velocity.

btw, how did you got bullet working into your project ?
I cannot for the love of god figure this out myself.
lhaw
Posts: 6
Joined: Tue Dec 28, 2010 9:04 am

Re: Getting proper friction?

Post by lhaw »

That does sound like a fairly good idea, though I'm not sure if it would be that easy to implement.
If the player started moving when there's also some sliding going on, stopping the force would cause an effect similar to walking on a pile of rubble, I believe. When stopped you stay put, but when you start moving the sliding accelerates too.
btw, how did you got bullet working into your project ?
I cannot for the love of god figure this out myself.
I'm very new to bullet too, so I just basically followed the bullet hello world tutorial, adding it to my code. It's nothing complicated yet, I'm just playing around to see what is possible, how to best do things etc.

What I had much trouble with was getting the terrain properly fed to bullet for collisions. Got that solved after a couple of hours, though.
lhaw
Posts: 6
Joined: Tue Dec 28, 2010 9:04 am

Re: Getting proper friction?

Post by lhaw »

Trying different shapes, I found a solution good enough, 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.
GameOn
Posts: 35
Joined: Mon Dec 27, 2010 10:46 pm

Re: Getting proper friction?

Post by GameOn »

Nice, thanks for the info !