I am playing with making a minigolf game using three.js and the ammo.js conversion of the Bullet Physics library but I am having some trouble getting the ball to move realistically.
(I've put a demo at penguinspuzzle.appspot.com/minigolf.html if you want to have a look at how this works in practice.)
What is a good algorithm to give more realistic motion of a minigolf ball?
In ammo.js there are options for friction, linear damping, and rotational damping.
As the ball rolls, the friction setting does not seem to have much effect.
I'm currently using
body.setRestitution(0.8);
body.setFriction(1);
body.setDamping(0.2,0.1); // linear damping, rotational damping
With high values of linear damping the ball seems to decelerate too fast.
With lower values it seems to take ages to finally stop.
When the ball is in the air it seems unreasonable to be applying linear damping at all.
I think the problem may be the linear damping in ammo.js which causes an exponential slow down.
I tried:
The results are shown below. It looks to me like the velocity profile is much closer to being linear than exponential.
Any suggestions for an algorithm to get ammo.js to be more realistic?
I spotted that you're using "regular" friction on a spherical object. In physics there is a separate concept, "rolling friction" for round objects. I don't know whether Bullet Physics supplies such a concept in its API. If it does, try replacing this with the rolling friction counterpart:
body.setFriction(1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With