Prediction: pending property
Available since
@irtio/client 5.0BrowsersNodeThe pending read-only property of the Prediction interface is the number of ticks the prediction has stepped ahead of the room’s state: inputs sent and not yet acknowledged, and idle ticks not sent.
Value
A number from 0 to 64.
Description
With sample, pending stays at about 2 plus half the round trip in ticks, and never reaches 0, because inputs are sent ahead of the room’s clock. To tell that the prediction has caught up with the room, read settled instead.
Idle ticks, those whose input idle says means the same as none, are dropped only when a state update arrives. In a room where nothing changes, no update comes, so pending climbs to 64 and stays there.
Examples
Showing input lag in a debug overlay
A debug overlay shows how many ticks the player runs ahead of the room, and the round trip that sets it.
// overlay.ts
import type { Prediction, RoomClient } from "@irtio/client";
export function overlayText(room: RoomClient, me: Prediction<unknown>): string {
return `ahead ${me.pending} ticks, rtt ${Math.round(room.rtt)} ms, ${me.settled ? "settled" : "catching up"}`;
}
See also
Runtime availability
| Browsers | Node | |
|---|---|---|
pending | 5.0 | 5.0 |