Friction on spheres?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
dweeb
Posts: 14
Joined: Tue Jul 15, 2008 11:17 pm

Friction on spheres?

Post by dweeb »

Let my first say VERY COOL ENGINE :)

I have a problem with spheres. I'd like to create a sphere that is pushed by a force and then comes to a stop after a while due to friction.

So I've setup a box with friction and a sphere with friction but there sphere seems to be ignoring the friction I set.

Do you have any advice how to solve this issue? It seems to work fine with boxes they obey the laws of physics and friction :o)

Any help is appricated!

Thanks
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Friction on spheres?

Post by Norbo »

The friction values are applied to the points of contact. Each individual contact generated while the ball moves around applies impulses to stop sliding, which leads to rolling. Since the friction coefficient corresponds to the surface sliding friction and not rolling friction, it won't really slow down the ball.

For the effect I believe you're looking for, which is essentially slowing the linear velocity of the ball, you have a few options. The quickest and most straightforward would be damping the sphere's linear velocity using (Entity).linearDamping. Perfect spheres tend to enjoy wandering around a bit (both naturally and due to some floating point issues), so it might take some tweaking to make it look exactly like you want.

Another option would allow you to use the sliding friction instead of damping, and the ball will definitely not wander. You can restrict the rotation of an entity by altering its localInertiaTensorInverse, each row corresponding to a local axis of rotation. If you set every element in the matrix to zero, it cannot rotate. This means, instead of rolling, it will slide- allowing your friction coefficients to slow its motion down. This is what I use for the character controller to keep it upright; you can see it being used in the DynamicCharacterControllerInput constructor. There are also some upright constraints, but they are less directly applicable to your situation.

Thanks for trying it out!
dweeb
Posts: 14
Joined: Tue Jul 15, 2008 11:17 pm

Re: Friction on spheres?

Post by dweeb »

Thanks that solved my problem :)
Post Reply