matter-js icon indicating copy to clipboard operation
matter-js copied to clipboard

When slowing down the engine, bodies gain upward momentum out of nowhere.

Open miyucomics opened this issue 3 years ago • 1 comments

I am making a game where you can enter slow-motion. At first, I used engine.timing.timeScale, which worked until I noticed the geometries floating upwards slightly before settling whenever I changed it.

I thought this was a side effect, that I would also make the calculations go slower, so I tried to counter it with this:

engine.constraintIterations = Math.round(2 / simulation_settings.timeMultiplier);
engine.positionIterations = Math.round(6 / simulation_settings.timeMultiplier);
engine.velocityIterations = Math.round(4 / simulation_settings.timeMultiplier);

It didn't help. Is there a reason my geometries gain momentum when I slow the simulation down? How can I fix it?

miyucomics avatar Jan 11 '21 21:01 miyucomics

Try out this experimental branch which improves timing issues and hopefully is more stable for this kind of effect:

https://github.com/liabru/matter-js/pull/777

liabru avatar Jan 21 '21 00:01 liabru