0
\$\begingroup\$

I'm just facing a problem that when I slow time and set fixedDeltaTime to timeScale * 0.02f the physics starts behaving really weirdly. I have a chain of hinge joints and it makes kinda wave when I slow the time down. I tried slowing the time without changing fixedDeltaTime and it worked normally (it was only laggy, which is normal), but when I change it, it makes the physics weird. Here is video showing my problem: https://youtu.be/wEakZ03bWso Notice the wave on the chain in the first test.

\$\endgroup\$
1
\$\begingroup\$

One of the reasons we use a fixed timestep is to make physics behaviour more consistent.

It follows from this that changing the fixed timestep mid-run makes the physics behaviour less consistent.

And long chains of interactions are one of the first places inconsistencies in iteration frequency will appear. The timestep imparts a kind of inertia to these long chains, limiting how far down the chain an influence can travel in a given window of time (based on how many iterations fit). At higher update frequencies, the same chain can behave in a more flexible/snappy/responsive way, while at a lower frequencies it can behave stiffer / more damped.

So, the most surefire solution would be to not change your timestep dynamically. Choose a compromise timestep that's small enough to give good responsiveness at slowed time, but large enough to not bog your game down in physics computations at regular speed, and use that at all times. You can enable interpolation on rigidbodies where the timestep causes a noticeable stutter to keep it looking smooth & fluid.

The other thing you can try is to compensate your physics sim when you change timesteps - say, changing the number of bodies in your chain, their friction and damping parameters - so that of the high-timestep and low-timestep versions come out similar. This sounds like a parameter-tuning nightmare though, with no guarantee that any perfect match exists.

\$\endgroup\$
  • \$\begingroup\$ Thanks for making it clear :) I'll try my best to get it fixed :D \$\endgroup\$ – sudoman281 Feb 10 '18 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.