Page 1 of 1

Quick question about friction

Posted: Fri Oct 05, 2012 4:44 am
by snoozbuster
So, my game requires some tricky frictions. Boxes and rollers need to interact in such a way that boxes roll smoothly along, not getting stuck between two rollers (too little) or tending to make "popcorn" (too much, boxes fly all over when the roller pushes them into a wall). However, boxes still need to slide down certain slopes. What would you recommend for ratios? I'm not looking for specific values, just something like slope friction < box friction < roller friction, and maybe an idea of how far apart to set static and kinetic frictions. Could you perhaps help with this? I've tried so many different values with little success. Here's the values right now:
box friction: 1.3 static, 1.3 dynamic
roller friction: 0.33 static, 0.33 dynamic
slope friction: 0.05 static, 0.05 dynamic
I know static friction should be higher that dynamic; is that maybe why I'm having this problem? Currently, the boxes are getting stuck between two rollers, although I believe the box/slope interaction is fine.

Re: Quick question about friction

Posted: Fri Oct 05, 2012 5:18 pm
by Norbo
What would you recommend for ratios? I'm not looking for specific values, just something like slope friction < box friction < roller friction
The material coefficients should not be considered in terms of a 'global' ratio like that. The per-object material coefficients are combined using a blending function to produce the interaction properties governing a single pair of objects. So, you probably want slope-box to be low, and roller-box to be a bit higher. Accomplishing that goal is separate from sorting the per-entity coefficients from low to high.

It may be easier to define the interaction properties between pairs of materials arbitrarily rather than attempting to puzzle out per-entity coefficients which produce the desired results.

To do this, shared a Material between all boxes, another Material between all rollers, and another Material between all slopes. Then, add an entry to the MaterialManager.MaterialInteractions. This overrides any material blending so you get exactly the combined coefficient that you want.

Here's an example:

Code: Select all

            MaterialManager.MaterialInteractions.Add(new MaterialPair { MaterialA = rollerMaterial, MaterialB = boxMaterial },
                                                     delegate(Material a, Material b, out InteractionProperties properties)
                                                     {
                                                         properties = new InteractionProperties
                                                             {
                                                                 StaticFriction = 1.2345f,
                                                                 KineticFriction = 0.12345f,
                                                                 Bounciness = 0
                                                             };
                                                     });
Another option is to specify your own default MaterialManager.MaterialBlender to accomplish something similar.

Once the friction pairs are decoupled, it should be more intuitive to tune the values to get the behavior you want.

[Technically, since rollers presumably don't interact with slopes, it's already decoupled- but having to work through the default material blender can make things less clear.]

Based on this:
or tending to make "popcorn" (too much, boxes fly all over when the roller pushes them into a wall)
the wall-box interaction should probably have its friction reduced, possibly to zero. It could still 'popcorn' the boxes out if box-roller was really high friction, but reducing the wall's contribution will mitigate it some.

Making the motors controlling rollers weaker could also help reduce the effect. It may allow boxes to get wedged in a bad spot more often if the roller can't forcibly clear it, though.
I know static friction should be higher that dynamic; is that maybe why I'm having this problem? Currently, the boxes are getting stuck between two rollers, although I believe the box/slope interaction is fine.
Static friction doesn't really need to be higher than dynamic. Unless you're trying to emulate the behavior of a very particular surface, using equal coefficients for static and dynamic will probably end up being just fine in most cases.

Re: Quick question about friction

Posted: Fri Oct 05, 2012 9:55 pm
by snoozbuster
Alright, thanks. That should be enough to go on.