Skip to content

InterpolationBuffer

Constructor

InterpolationBuffer.new(minBuffer: number, maxBuffer: number, alpha: number) → InterpolationBuffer

Creates a new interpolation buffer instance.

ParameterTypeDescription
minBuffernumberMinimum interpolation buffer in seconds.
maxBuffernumberMaximum interpolation buffer in seconds.
alphanumberSmoothing factor for the moving average latency.

Returns:
A table representing the InterpolationBuffer instance with the methods below.


Properties

PlayerLatencies: { [networkId: number]: { averageLatency: number, deviation: number, lastLatency: number? } }

A dictionary storing per‑player latency data, keyed by networkId.
Each entry tracks:

  • averageLatency → smoothed round-trip time (RTT)
  • deviation → moving deviation (jitter estimate)
  • lastLatency → most recent latency sample

Methods

RegisterPacket(networkId: number, serverTime: number, tickRate: number)

Registers an incoming packet for latency tracking.

ParameterTypeDescription
networkIdnumberUnique ID representing the player or NPC.
serverTimenumberTimestamp from the server for when the packet was sent.
tickRatenumberSending tick rate (Hz) for this entity.

GetBuffer(networkId: number, tickRate: number) → number

Calculates the current recommended interpolation buffer for a given network ID.

ParameterTypeDescription
networkIdnumberPlayer or NPC network ID.
tickRatenumberTick rate (Hz) for this entity.

Returns:
A buffer duration in seconds, clamped between minBuffer and maxBuffer.