TExcelTAD
Home › Multiplayer Game Networking › Interest Management

Interest Management

A 100-player match has 100 players, hundreds of projectiles and thousands of objects. No client needs all of them: a player in the north of the map doesn't care about a door opening in the south. Interest management (also called relevancy, area of interest or network culling) decides, per client, which entities to replicate. It is the main reason large games fit in their bandwidth budget, and it's also an anti-cheat measure: information you never send can't be read by a wallhack.

Ways to decide relevance

Method Idea Good for
Distance send entities within radius r of the player open worlds, battle royales
Grid / cells world split into cells; a client sees its cell and its neighbours large maps with many entities; cheap to update
Rooms / zones relevant if in the same room, building or zone indoor levels, MMO zones, instanced dungeons
Visibility (PVS) precomputed potentially-visible sets per area, or line-of-sight checks competitive shooters (hides players behind walls)
Teams / ownership always send teammates, your own projectiles, objective items everyone combines this with the others
Always relevant game state, scoreboard, the match timer global objects

Engines expose these: Unreal has NetCullDistanceSquared, bAlwaysRelevant, bOnlyRelevantToOwner and the Replication Graph for large games; Unity Netcode for GameObjects has per-object network visibility (CheckObjectVisibility, NetworkShow/NetworkHide); Mirror and FishNet ship interest-management components (distance, spatial hashing, scenes, teams); Godot's MultiplayerSynchronizer has per-peer visibility filters. See Engines & Frameworks.

A grid in 40 lines

A spatial grid is the workhorse: put every entity into the cell its position falls in. A client's interest set is everything in the 3×3 block of cells around it. Updating an entity is O(1) when it moves, and a query only touches nine cells. When an entity enters a client's interest set, the server sends a "spawn" with its full state; when it leaves, a "despawn". In between, normal delta updates.

ts · try it yourself
const CELL = 50;
type Ent = { id: string; x: number; y: number };
const key = (cx: number, cy: number) => `${cx},${cy}`;
const cellOf = (e: Ent) => [Math.floor(e.x / CELL), Math.floor(e.y / CELL)];

class Grid {
  cells = new Map<string, Set<Ent>>();
  where = new Map<Ent, string>();
  update(e: Ent) {
    const k = key(...(cellOf(e) as [number, number]));
    const old = this.where.get(e);
    if (old === k) return;
    if (old) this.cells.get(old)!.delete(e);
    if (!this.cells.has(k)) this.cells.set(k, new Set());
    this.cells.get(k)!.add(e);
    this.where.set(e, k);
  }
  near(e: Ent): Set<string> {
    const [cx, cy] = cellOf(e);
    const out = new Set<string>();
    for (let dx = -1; dx <= 1; dx++)
      for (let dy = -1; dy <= 1; dy++)
        for (const o of this.cells.get(key(cx + dx, cy + dy)) ?? []) if (o !== e) out.add(o.id);
    return out;
  }
}

// A 500 x 500 map: the player, a few others, and 40 crates on a regular pattern.
const grid = new Grid();
const me: Ent = { id: 'me', x: 60, y: 60 };
const ents: Ent[] = [me, { id: 'ann', x: 120, y: 80 }, { id: 'bob', x: 400, y: 420 }, { id: 'cy', x: 210, y: 70 }];
for (let i = 0; i < 40; i++) ents.push({ id: `crate${i}`, x: 25 + (i % 8) * 60, y: 25 + Math.floor(i / 8) * 100 });
ents.forEach((e) => grid.update(e));

let known = new Set<string>();
for (const step of [0, 1, 2, 3]) {
  me.x = 60 + step * 50;                         // walk east, one cell per step
  grid.update(me);
  const now = grid.near(me);
  const spawn = [...now].filter((id) => !known.has(id) && !id.startsWith('crate'));
  const despawn = [...known].filter((id) => !now.has(id) && !id.startsWith('crate'));
  const crates = [...now].filter((id) => id.startsWith('crate')).length;
  console.log(`me at x=${me.x}: replicate ${now.size}/${ents.length - 1} entities (${crates} crates)` +
    (spawn.length ? `  spawn ${spawn.join(',')}` : '') + (despawn.length ? `  despawn ${despawn.join(',')}` : ''));
  known = now;
}
me at x=60: replicate 7/43 entities (6 crates)  spawn ann
me at x=110: replicate 5/43 entities (4 crates)
me at x=160: replicate 6/43 entities (4 crates)  spawn cy
me at x=210: replicate 5/43 entities (4 crates)  despawn ann

Instead of 43 entities per snapshot, the client gets 5 to 7, and players appear and disappear as they enter and leave the neighbourhood.

Hysteresis: don't flicker at the border

A player standing on a cell border (or exactly at the relevance radius) would spawn and despawn every few ticks, each time costing a full-state spawn message. Use two thresholds: become relevant at radius r, stop being relevant only beyond r + margin (or a few seconds after leaving). The same trick applies to rooms and visibility checks.

Interest management as anti-cheat

A wallhack can only draw what the client knows. If the server only sends enemies the player could plausibly see (same room, line of sight with a margin for latency), there is nothing to draw. Competitive shooters run server-side visibility checks for exactly this reason. Be careful with the margin: if an enemy becomes relevant only when already visible, they "pop in" a tick late, which players hate even more than wallhacks. Send them slightly before they become visible (e.g. based on where they will be in the next few hundred milliseconds).

Other uses of "who needs this?"

  • Update rate by distance: nearby players at full rate, far ones every 3rd snapshot (Bandwidth Budgets).
  • Level of detail: far players without animation details or with coarser quantization.
  • Server sharding: the same idea at a larger scale splits a world across several server processes (zones), each owning a region and handing players over at the borders.

Test yourself

With a uniform grid, which cells does a client's interest query usually cover?

  1. Only its own cell
  2. Its own cell and the 8 neighbouring cells
  3. Every cell on the map
  4. Cells with players only

Why add hysteresis to relevance checks?

  1. To save CPU on the grid
  2. So entities on the border don't spawn and despawn repeatedly, each time costing a full-state message
  3. To make wallhacks work
  4. Because UDP needs it

How does interest management help against wallhacks?

  1. It encrypts positions
  2. Enemies the player can't plausibly see are never sent, so the client has nothing to reveal
  3. It bans cheaters automatically
  4. It doesn't