Distance between server and clients, packet hops, a server’s tick and update rate, and a plethora of other issues contribute to multiplayer lag – here’s how to address it.
What is network latency?
Online games have issues that single-player or LAN-only games don’t have to worry about, such as jitter, round-trip time (RTT), or packet loss.
Any kind of delay between sending, receiving, and queuing information between clients and servers can cause an issue for gameplay. For a full list of definitions and problems, check out this guide here.
To successfully address latency problems, you need to consider the priority and relationship between the following elements:
- Accuracy and consistency
No solution is perfect, and every way to approach latency issues has strengths and weaknesses. The key is to find the way that works best for your game and this guide will help you understand how to make that decision.
How does this work in reality?
If you want to know how this might end up looking in your game, consider the example of a game where you cannot kill imps from a certain distance.
If you specify in your client logic that you can't kill these imps more than 10 meters away, but the "kill imp" message is a server RPC that doesn’t check distance server-side, players can forge that network message to bypass your client side logic.
Unfortunately, some people will always try to mess with your game so you should always keep in mind you can never fully trust clients. For the sake of those poor imps and all others playing your game, your server needs logic to validate player actions coming from clients.