I am currently using the Babylon.js game engine, and I understand that the recommended physics engine is Havok. However, I am having trouble creating a rope using Havok physics.
While this approach works to some extent, I am facing an issue where the rope appears to stretch significantly when a weight is applied to it. The rope behaves more like a spring, which is not the desired effect. Specifically, when I increase the weight of the attached ball, the rope stretches too much, losing its realistic appearance.
Could someone please guide me on how to create a rope that does not stretch, maintaining a more realistic behavior without the spring-like effect?
Havok is solving the physics iteratively, and by definition the constraint will never be “respected” because it’s basically waiting for it to be “out of law” (ex: distance constraint out of bound) to “solve” this by “slightly pushing” the joints toward the right place. Then it adds a damping effect so that things don’t go crazy.
In order to better understand you can have a look at my project with Custom wire physics using GreasedLines and have a look a the custom (no Havok) physics :
// Gravity
this.speed.y -= GRAVITY;
// Apply forces for all linked joints
for (const [joint, dist] of this.links) {
const d = this.pos.subtract(joint.pos).length();
if (d !== dist) {
const dir = joint.pos.subtract(this.pos).normalize();
const pos_ = this.pos.add(dir.scale(d-dist));
this.speed.addInPlace(pos_.subtract(this.pos).scale(ELASTICITY));
}
}
// Damping effect
this.speed.scaleInPlace(Math.max(0.5, 1.0-DAMPING*Math.pow(this.speed.length(), 0.2)));
It’s not exactly Havok, but the principle is very close :
Gravity
if (d !== dist) → act on joint if constraint is not OK
Damping
Now, about solving your issue :
Gravity acts the same on any mass (heavier object won’t fall faster)
Theorically only reason why you would need the ball to be very heavy, is because you want it “much heavier” than other objects (for interaction purpose)
Then, instead of having the ball crazy heavy, try to have the other objects lighter.
There is an equilibrium to be found, a bit like for render params where everything should remain into some bounds : a mesh should not be of size 0.0001 as well as should not be of size 10000.0, etc…