flame-engine / forge2d

A Dart port of Box2D
BSD 3-Clause "New" or "Revised" License
181 stars 26 forks source link

Static and Kinetic Friction #88

Open tojewel opened 11 months ago

tojewel commented 11 months ago

Hi all,

Thanks for developing such an amazing framework for Flutter. Using Froge2d, I am trying to develop a 2D board game (named Carrom) exactly like this one: https://play.google.com/store/apps/details?id=com.miniclip.carrom

Everything went fine until I hit the roadblock on implementing the Friction between the board and the pucks (bodies). If you look at the game in the link I provided, you will see the pucks are kind of steady when not applying enough force from a collision. On the other hand, they implemented the proper physics for Static and Kinetic friction when a body slides over a plane (explained here https://www.youtube.com/watch?v=RIBeeW1DSZg).

I tried to replicate that using restitution and the friction properties of the fixture but looks like the restitution is not exactly for this and the friction property is really for the collisions of two bodies, having nothing to do with the friction between the bodies and the unlying plane.

I tried using the FrictionJoint but that is also not implement the correct friction algorithm as per physics.

I am more interested in implementing static friction for my game. Tried looking into the Collision code but the code is very cryptic for me.

Wondering, if anybody had the same issue, or if you have any suggestions.

Feel free to check out the game I am developing here https://gg-carrom.web.app/

Thanks!