In this lesson, you will learn how to minimize network overhead by streamlining your data serialization and narrowing the scope of information delivered to each client.
Efficient Data Serialization
Bandwidth is often wasted by sending redundant or bloated data structures. Instead of serializing entire object states, focus on sending only the delta—the minimal set of changes since the last update. Avoid sending high-precision floats (like double or float) when a normalized short or byte will suffice. For example, if your character’s rotation is restricted to 360 degrees, you can map the 0–360 range to a single unsigned byte (0–255), drastically reducing the packet size.
// Instead of sending a full Quaternion (16 bytes),
// send a packed byte (1 byte) for Y-axis rotation
byte packedRotation = (byte)((transform.rotation.eulerAngles.y / 360f) * 255);
Implementing Interest Management
Sending the state of every entity in your game world to every client is a recipe for network congestion. Interest Management acts as a filter, ensuring the server only pushes updates for entities that are "relevant" to a specific client.
The most common approach is a Proximity-Based system. The server maintains a grid or a spatial partition of your game world. A client only receives updates for entities within a specific "Area of Interest" (AOI). If an entity is behind a wall or beyond a certain distance, the server stops broadcasting its state to that client, saving significant bandwidth.
Choosing Update Frequencies
Not every object requires 60Hz replication. While player movement might need frequent updates to feel responsive, environmental interactables or distant NPCs can be updated at much lower intervals (e.g., 5Hz or 10Hz). By decoupling the refresh rate from your frame rate, you can prioritize critical data while keeping total packet traffic well within the client’s bandwidth limit.
By combining compact data packing with smart filtering, you ensure that the server's precious upload capacity is reserved for the data that actually influences the player's immediate experience.
Key Takeaway: Optimize bandwidth by serializing only essential changes using reduced-precision types and implementing interest management to exclude irrelevant entities from client updates.