Thank you for your reply!
True, for client-only effects, there’s no network delay because we don’t wait for the server to receive the data, or for the server to update our visuals. But with computers, nothing is ever really instant. At its fastest, even client-only, when we press a button, we don’t see the change until the very next frame. This happens within milliseconds, at least according to the below video, and since Microgames doesn’t have glaring issues with this kind of lag, I want to push that advantage if I can.
As a source, I learned about input lag from Masahiro Sakurai’s game design video on the topic, he explains it well:
Thanks for trying it out! I double-checked to be sure, and the Pistol’s bullet is currently owned by the server. Ping will always vary depending on how good players’ Internet connections are. That said, the Pistol is probably a good example of network lag, not input lag. Input lag doesn’t require a network connection at all - single-player games can have it as well.
At first, it would seem like yielding code would make delay worse. Why not run code instructions the moment they’re received? While this may slow the code slightly, it maximizes frame rate. Here’s how:
Roblox orders all the instructions via it’s Task Scheduler - a system that handles one task after another. According to their own guide on their developer page, it is best to do certain actions (like setting velocity) in Stepped/PreSimulation, then do other actions (like reading position) in Heartbeat/PostSimulation.
If we switched that order around - we make something move in Heartbeat/PostSimulation instead - then according to their diagram, we have to wait for the game to, on the next frame:
- Read player input
- Render the frame (we’ll have to wait for the frame AFTER this one to see the motion at all!)
- Receive network data
- Finally, update physics (our movement finally occurs)
Using Stepped:Wait() tells Roblox that it can handle other tasks for now, and come back to this once we’re in the correct portion of the frame. That way, we don’t wait for Roblox to do a bunch of other tasks first.