Networking · class

PredictingClient

A machine that predicts its own player and corrects toward the authority.

Explained in Networking and rollback.

class PredictingClient<S>
import { PredictingClient } from '@driftengine/network';

Constructor

new

constructor(options: ClientOptions<S>)
ParameterTypeDescription
optionsClientOptions<S>

Properties

NameTypeDescription
selfreadonlyPeerId

Accessors

NameTypeDescription
correctionsgetnumberHow many authoritative states have been applied. Each one is a rewind.

Methods

submit

submit(tick: number, payload: Uint8Array): void

Send this input and, when predicting, apply it locally on the same tick.

ParameterTypeDescription
ticknumber
payloadUint8Array
More

No input delay, unlike lockstep. A delay there buys exactness for everybody; here the authority is the source of truth anyway, so delaying the local input would add latency to the player's own controls and buy nothing.

poll

poll(): void

advance

advance(dt: number, tick: number): void
ParameterTypeDescription
dtnumber
ticknumber