Ensure that the forces being applied with Havok are the same for different clients without relying on deltaTime?

So I have a networked racing setup that is applying force to a body but it seems that the person who has 60 fps is at about half the speed as the person who is at 144. I know I could be applying deltaTime to all of my calculations, but its going to take quite some refactoring to do that.

Would it be bad practice to scale the physics timestep by the animationRatio? It seems to make both clients run at the same rate now but I’m worried there might be some problems caused by that.

AnimationRatio is calculated from DeltaTime (as far as i recall), so it would/should give the same result.

Only thing to keep in mind is desynchronization i believe :thinking: …and maybe lag spikes… i don’t remember if AnimationRatio is calculated from an fps average, or just the last 2 frames…
i do recall dealing with bugs from DeltaTime spikes due to the browser being minimized or simply being in another browser tab for a while before going back to babylon

1 Like

I set the engine to keep rendering even if minimized so that should solve that spike hopefully!

cc @Cedric to get his ideas

Racing game don’t have their physics running at the speed of the display. Usually, it’s much more (even up to 1Khz). Then for rendering, that hirez physics is sampled using linear interpolation for example.

So, fixed frame rate, freq > max display speed. same freq for everyone.

So are you advising against adjusting the frequency per user? I really don’t want to have to refactor how Im applying all the forces, but if you can see that scaling the frequency per user to match everyone up is going to cause problems in the long run then that might be needed.

No, I think he’s saying that your physics sim should run at a very high, fixed time step. Rendering is done by sampling the physics values every frame.

The underlying physics simulation does its thing 1000x per second, (at 1k fps) of which the camera only “sees” 30-60, spread evenly over those 1000 frames.

HTH!

That gets me back to the issue of different forces being applied at different amounts though, Id have to refactor the way I apply the forces to use deltaTime which would break a bunch of other things I have going. Sounds like that is the suggested solution though I just really wanted to avoid it.