I’ve come across a weird situation here. I have a relatively complex physics object, made out of several rigidbodies connected by joints. This can get quite heavy on the physics update, especially if time is sped up.
I’ve noticed that when Time.timeScale is changed, the physics time step remains the same, but under the new time step. That means at 2x real time, the physics are doing twice as many iterations as before.
So, I found that it’s possible to change the fixedDeltaTime at runtime, to compensate for that. I set it up so that fixedDeltaTime = 0.02 * Time.timeScale. So no matter what I set the time scale to, there will always be the same number of physics steps per real-world second.
I expected to lose some accuracy by doing this, but not as much as what I actually saw. To test it, I set the fixedDeltaTime to 0.01 at 1x time scale, and increased it to 2x later. I assumed that if all went normally, at 2x time the physics should be just as accurate as they were in the previous run. But that’s not what happened. I saw my joints start to wobble and lose much more accuracy than they were supposed to.
So I can only conclude that the tweaking of fixedDeltaTime itself is introducing more loss of accuracy than what would result from the futher-spaced time steps alone.
This seems very weird, so I had to ask here if anyone has ever seen this before, and if there is a way around that. Maybe I’m missing something here… Unity’s docs really don’t help much in these more advanced topics…
Did you change it outside of FixedUpdate()? Which factor are we talking about, between 1 and 2?
Is your simulation running equally worse if you change Fixed Timestep in project settings?
I don’t know what your game is about, but I would try to find a timestep which works smoothly and wouldn’t change that.
Your idea might not waste any cycles on increased speed but you would certainly waste some on normal or reduced speed (given you need no extra accuracy at lower timeScale).
I need to be able to manipulate the physics time step, because the game needs it’s time compression. Orbiting around would be much too boring without a way to speed up time.
Also, this idea to set the time step to double-time was only for testing purposes. I wanted to see if the loss in accuracy was greater than it should be by just the loss in step density. It really does seem to be.
I’ll try the FixedUpdate thing. Let’s see if it works.
Just to follow up, I tried moving the line that updates Time.fixedDeltaTime to inside the FixedUpdate loop, but it didnt have any effect. The rockets are much more wobbly than they should be at that level of precision.
Starting the game with a doubled Time.fixedDeltaTime value doesn’t produce a simulation as inaccurate as setting it during simulation.