Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to fix this friction inconsistency in Matterjs #1311

Open
cod3kid opened this issue Aug 16, 2024 · 3 comments
Open

How to fix this friction inconsistency in Matterjs #1311

cod3kid opened this issue Aug 16, 2024 · 3 comments

Comments

@cod3kid
Copy link

cod3kid commented Aug 16, 2024

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?

@MLH-AIDS
Copy link

MLH-AIDS commented Aug 16, 2024

  • 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
Copy link

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

@cod3kid
Copy link
Author

cod3kid commented Aug 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants