Getting friction to work properly

Hello,

I dont know if someone had this kind of problem, but I know I must be doing something wrong. In the game I am coding(post link), there is a "thing" with friction which bothers me, and maybe it extends to other problems, I am sure I do something wrong...
The problem I encounter is: When my character pushes a box which has others above it, the box above "stays" as if there was no friction between them, instead of moving them at the same time...

The curious case is, if I use a mousejoint, dragging the box against the floor, the other one follows dragged with friction if I do it slowly...
Some screens show it:
Image
Image

**My character, consisting of a blob (first model)of 80 bodies and 1 central body with this data:
- Outer masses Density:0.01 Radius:0.3
- Inner mass Density: 0.45 Radius:0.3
All are connected with box2d distance joint "made soft", that is with some damping and frequency.

**The boxes trying to move have this data:
- Width and Height: 7 and 6 (aprox)
- Density:1000
- Friction: 1.0 (increased to try with no apparent effects)

**The gravity for the scene is 40

**All moving bodies have IsBullet to true

**All bodies have angular damping = 0.1 lindamping = 0

I use applyimpulse to move my character TO THE CENTER MASS (of value 0.18), so by joint, it pushes and transmit this force to outer masses, which push the box. I changed it to a bigger applyforce, but it doesnt change the behaviour. It is strange because the pushing force is small, yet it makes the box above not to follow...

I dont know where to attack... is gravity too small (i think it isnt), or densities too small, or the force of soft distance joint is affecting to the result? I dont know... Someone has an idea where is the problem? Friction works in expected ways when boxes move in slopes, or if I change friction of boxes and run again...
How is the character being driven?

Why are all the bodies marked as bullets? I recommend against using continuous collision between dynamic stacking bodies.
Hello, thanks for answering!
The character is moved by "ApplyImpulse" to the center body. This, effectively moves everything in the direction, given by cursor keys (left, right, up-left, up-right...). This direction (a unit vector pointing the composed direction to move), is scaled by a max scaling force, the parameter I use to change how much force I put to character. (It is a value of 0.18).

I post code I use to control movement of character (I use the famous method 'FIX YOUR TIMESTEP' , that is why this call to "IsPhysicsStepped", because there can be updates where physics didnt update, and we continue applying accumulated forces to control the character...):

Code:
//Command to move blob
void BlobController::MoveBlob(const Vector2& direction)
{
   //IF  - Controller active and physics is stepped (we can apply forces)
   if(mActive && mPhysicsMgr->IsPhysicsStepped())
   {
      assert(mCenterBody);
      //IF - Blob "Not flying"
      if(mBoundingCollisions > 0)
      {
         //IF - Speed not maximum
         if(mCurrentSpeed.Length() < mMaxSpeed)
         {
            //Get direction in b2Vec
            b2Vec2 movforce(static_cast<float32>(direction.x),
                        static_cast<float32>(direction.y));
            movforce*=mMaxControlForce; //Scale to control force
            mCenterBody->ApplyImpulse(movforce,mCenterBody->GetPosition());
            //mCenterBody->ApplyForce(movforce,mCenterBody->GetPosition());
         }//IF   
      }//IF
   }//IF
}


I changed the method of moving the character from "ApplyImpulse" to "ApplyForce" (With bigger scaling of course), but the results are the same.... I dont know where the problem is...

I used the property IsBullet to true, as when putting the character on top of a stack, I experienced a deep penetration of bodies, I suppose due to soft-distance joint...
Does the friction problem go away if you turn off bullets?
I tried and it continues the same. I am using v 2.0.1, not SVN. Should I upgrade to it before trying more things?

I post a version showing the problem in movement:
HYDRO_Friction

Edit: I made the character to be a single body with circular shape, and this doesnt happen. It is certainly something with my creation of the model, or with solving of b2Distance joint.... I will continue investigating. But I would like to know if I should upgrade to new version (SVN)?

Edit2: I certainly found the problem is with the distance joint, or the body being compound (i am most inclined by distance joint). I made the character back as it was defined again (80 bodies, connected in blob fashion to center and between "skin"), but making all joints rigids (that is damping and frequency 0), and the problem arises again...
What happens when you set friction to the max value?
So you have a bunch of small circles colliding with the box? But you are only pushing the central body? The Box2D solver is sequential, so the ordering of the constraints might be causing the problem.

Try one or more of these:

- apply the movement force to all the perimeter circles
- filter the collision so the perimeter circles don't collide with the box
- make the circles have fixed rotation.
toucansam wrote:
What happens when you set friction to the max value?

The same. In fact I try now allways with friction to 1.0 (I suppose you refer to max by 1.0)

Erin Catto wrote:
Try one or more of these:

- apply the movement force to all the perimeter circles
- filter the collision so the perimeter circles don't collide with the box
- make the circles have fixed rotation.


I tried it:
- Circles had fixed rotation before, so I didnt change it.
- If outer circles dont collide with the box, it behaves the same as when making the character only a cirle-shaped body, that is, correctly (upper box gets dragged correctly).
- Applying the movement force to all perimeter circles has the same effect on the movement of the box.

But, messing with parameters, I found changing b2_linearSlop from 0.05 (original, i didn't touch it) to a lower value (0.0001 aprox.), cause the friction to behave better, but it becomes unstable (I suppose it is obvious because of floats), in a manner that the upper box can slide forward and even without touching.

So, my concern maybe is that I need to make my character heavier, so I apply bigger forces to it, and I dont have this small increments which are causing such unstabilities, and maybe lowering a bit this linear slop? Would it be wise to change densities (dimensions would break my project right now) of character bodies, and scale control and other related forces?

I am currently using a timestep of 1/80 with 10 iterations.
Yeah, using those small circles to interact with dynamic bodies is going to give you a lot of grief. You might want to do the soft body stuff on your own, and just use a single shape for the character in Box2D.
I don't think I have the experience nor knowledge to do it by myself and integrate it inside Box2D... I have to use it, as my core game mechanics are rigid-body. It is only my main character, which has to be kinda soft...

I will try to tweak some values and get an acceptable experience. Performance is not a great issue here, as I don't plan to have lots of bodies at the same time in a scene (puzzle game).

Original thread: https://box2d.org/forum/viewtopic.php?t=4000