I’ve been having alot of performance issues with my game after the 1.5 update and they seem to be related to the maximum allowed timestep. At the default setting my game is choppy. But when I lower it to .033333, the game plays much smoother. I don’t understand why this would change the performance since my game shouldn’t be dropping below 30 fps, and the maximum allowed timestep shouldn’t be kicking in.
So why is this changing the performance of the game?
I’m talking about the new setting beneath the fixed timestep, the maximum allowed timestep.
The point is it shouldn’t affect the performance of the game, only when the physics calculations should slow right? I’m trying to figure out why, if left at the default setting, the game becomes really choppy. The timestep is set at .02, I think that is the default. I think the default of the maximum allowed timestep is .3.
Oh, right…I’m actually not sure about that, since I just left it at .1 and it had no effect, but I’m not using physics at all (I have the timestep at 1.0), so that’s not really a good indicator of anything.
I’ve been struggling with this for a while too. My game is running at 60fps and almost every move is happening with deltas, which should allow smooth frame-rate changes. If I lock the game at 30 everything works completely different and choppy, which I can’t really figure out. Even simple delta changes (within 5-10 frames above 40) is creating a choppy experience.
In both cases the limit should not be kicking in.
Strange thing, if I follow a rigid body running in fixed update with a camera running in a regular update, its so choppy its unbearable. Even a low pass filter doesn’t help. Each update’s delta should compensate for the difference, but guess I got something wrong.
I thought I was completely clear on how these update functions worked, but I’ll review this and post my findings. Let us know how it goes for you.
I was expecting to have a smooth framerate change with at least 6 miliseconds available. The player should not notice mayor difference in perceived speed. But somewhere I’m not getting this right, and as soon as I go down a few frames the perceived speed also goes down. I’ve checked my fixedstep functions and my updates.
I’m totally sure there is something wrong in my setup, but haven’t figured it out, since I’ve been working on several other stuff.
sorry Moss, hope I’m not hijacking your post and this leads closer to a solution
so the Unity docs explain a bit how the fixed frame rate is computed, by advancing the fixed rate until it matches (approx) the variable time passed
this leads to possible over/under shoot (causing jerkiness), which can only be fixed (from what I know) using interpolation, which unity provides for rigidbodies
this doesn’t solve any problem, but explains a few things
i’ve tried everything, but currently handle all input in Update and all physics in fixed.
I do have a CharacterController which as much as I would like to have in FixedUpdate it just doesnt cut it. And I’m moving the character in Update, to get the sharp 60fps feeling.
But when the frame rate lowers or I cap it to 30, the character controller just goes jerky.
Looks like it doesn’t sync correctly to the variable sampling. Some accumulation is being lost or its not being distributed correctly along the frame time.
if you timestep is longer than visual framerate (or quite close to it) you should use Interpolation to get rid of jerky moves
I wouldn’t advice to keep fixed and maximum timestep that close to each other. There is no guarantee (even if you set kFPS to 30) that you will have 33ms per frame. One frame can be a bit longer and another can be a bit shorter, therefore physics can be “slowed down” for every other frame resulting in jerky illusion. I would suggest setting maximum timestep to 0.1 instead.
I no longer think this is a physics related issue. I took out all the physics and am getting the same results. I just doesn’t seem to be syncing to 30 fps correctly. I’m stripping my project down to just the rigidbody and camera and submitting a bug report, I don’t know what else i could do.
Hello,
Moss submitted sample shows that “maximum allowed timestep” works as designed. Some details:
his “fixed timestep” is 0.01, which means that physix, fixedUpdate and animations should be processed every 10 ms
when your frame time is ~33 ms then fixed loop is executed 3 times on average
but frametime isn’t fixed constant and depends on many factors including your scene state, OS background taks, etc.
because of 3. reasons frametime sometimes can reach 40-50 ms, which means that fixed step loop will be executed 4-5 times
when your fixed timestep tasks are pretty heavy then time spent on physix, fixedUpdates and animations extend your frametime by another 10 ms, which means one more additional iteration of all these fixed timestep tasks
in some unlucky cases process described in 5. could extend to 10 and more times of processing fixed step loop
that’s why “maximum allowed timestep” was introduced, it is the method to limit how much times physix,fixedUpdates and animations can be processed during single visual frame.
if you have “maximum allowed timestep” 100 ms and your “fixed timestep” 10 ms, then for fixed step tasks will be executed up to 10 times per visual frame. So sometimes small performance hitches could trigger big performance hitches because of increased fixed timestep iteration count. By decreasing “maximum allowed timestep” to 30 ms, you are limiting max fixed step iteration count to 3 and this means that your physix, fixedUpdate and animation won’t blow your frametime up very much, but there is some negative effect of this limiting. Your animations and physics will slow down a bit when performance hitch occurs.