matter-js icon indicating copy to clipboard operation
matter-js copied to clipboard

How to fix this friction inconsistency in Matterjs

Open cod3kid opened this issue 1 year ago • 3 comments

When a sprite has a mass of 50 and friction of 0.001, if I apply a velocity on X direction, it travels 100 units before coming to rest. But when a sprite has a mass of 100 and friction of 0.002 (I've increased friction value because I've increased the mass), if I apply a velocity on X direction, it travels 105 units before coming to rest.

Why is that? I'm multiplying the friction value based on the mass of the sprite to make it consistent. But it is not. Am I missing something?

cod3kid avatar Aug 16 '24 11:08 cod3kid

  • A Number that defines the friction of the body. The value is always positive and is in the range (0, 1).
  • A value of 0 means that the body may slide indefinitely.
  • A value of 1 means the body may come to a stop almost instantly after a force is applied.
  • The effects of the value may be non-linear. (Look at here!)
  • High values may be unstable depending on the body.
  • The engine uses a Coulomb friction model including static and kinetic friction.
  • Note that collision response is based on pairs of bodies, and that friction values are combined with the following formula:
  • Math.min(bodyA.friction, bodyB.friction)

MLH-AIDS avatar Aug 16 '24 15:08 MLH-AIDS

And the friction force in the real world is determined by the coefficient of friction and pressure, and changes in mass can affect pressure. But I don't know if this physics engine has this concept or not

MLH-AIDS avatar Aug 16 '24 15:08 MLH-AIDS

@MLH-AIDS Yes, it is non-linear. But is there a way to fix it? That's my question, thank you for your response

cod3kid avatar Aug 16 '24 21:08 cod3kid