In my game, the goal is to hit an object tied to a pole with a rope, causing the object to swing around. The more times players can hit the object without it touching the pole, the higher their combo multiplier will go.
This works fine when testing on a local server in Studio, but in a real game instance, it’s so slow and laggy that the object barely moves when players hit it. For reference, the highest combo I could get in Studio was 8x, but the highest combo I can get in-game is just 3x.
I could probably improve it by exaggerating the power of the physics forces, but that feels more like a hacky workaround than an actual solution.
How can I make the physics always behave the same, even when the server slows down or clients are experiencing lag?
I’m not very experienced in this, but my guess is that you’ll have to optimize your Roblox game quite a bit, perhaps server client communication and run as much as possible on the client.
One thing you can do is run all of the motion on the client. One very general approach is to replicate the information needed to calculate motion. For example:
At some point the server detects a hit (whether that’s server side hit detection or client side with server validation, doesn’t really matter). The server can then generate the information needed for all clients to compute what the resulting motion will then look like. For example:
Time motion should begin
Magnitude of Force upon the object
Direction of force upon the object
Etc.
Then, you can replicate that information to all the clients so that they know where the ball should be. This solves some issues like ping/lag, because if one client (say hits a lag spike) and gets the information super late (relatively), they should be able to still accurately compute where the ball would be at the current time (you can use the time that motion began vs. the time it currently is to predict where the ball should be at the moment/compensate for any time lost).
That’s one basic approach that might be worth considering.