GDNative-Ropesim icon indicating copy to clipboard operation
GDNative-Ropesim copied to clipboard

Any way to have the rope respect time_scale?

Open fremachuca opened this issue 3 months ago • 2 comments

Hey y'all,

I change the time_scale of my game as an accessibility option, but unfortunately the rope behaves completely differently instead of just being in "slow motion".

Also, thank you for the amazing plugin!

Cheers!

fremachuca avatar Sep 11 '25 01:09 fremachuca

Unfortunately that is a limitation of this addon. It uses Verlet integration for simulation rather than Euler integration like common physic engines. The reason is that Verlet integration is very simple and efficient. A downside is that it isn't fully FPS independent, as it determines velocities by taking the position difference of the rope points between last and current frame. That means, when changing the framerate (delta) the movement steps become larger or smaller, which in turn results in faster or slower velocities and thus completely different behavior and not just slow-motion or fast-forward. Hence, the only framerate independent parts of the simulation are gravity and damping. And since time_scale is essentially a delta multiplier, it doesn't work as expected.

So, there is no clean solution. I'll think about it, maybe I find a simple hack to approximate the effect of time_scale. Otherwise, you're out of luck unfortunately. You can try to tweak gravity, friction and constraint iterations to simulate time_scale, but that's all you can do for now.

mphe avatar Sep 11 '25 08:09 mphe

I gave it some thought and I think the only way to achieve this is by implementing custom tick management. Depending on time_scale, rope updates would be skipped every few frames (time_scale < 1.0) or would run twice every few frames (time_scale > 1.0). This way the simulation can be sped up or slowed down without affecting the behavior (theoretically). If frames were skipped, interpolation must take place to keep the rope animation smooth. In that case, special care has to be taken to keep tools like RopeHandle working properly.

It isn't insanely difficult to implement, but it's still quite a bit of work. I'll keep this issue open. If more people need this or when I get a burst of motivation the feature will come. But at the moment this has no priority for me I'm afraid.

mphe avatar Sep 12 '25 10:09 mphe