Skip to content

API Function defineInput

github-actions[bot] edited this page Nov 24, 2026 · 3 revisions

Function: defineInput()

function defineInput<S>(
   id, 
   schema, 
   options?
): InputDef<S>;

Defined in: src/engine/net/input.ts:159

Declare an input stream. Both ends of a connection must define the same streams, with the same schemas (the handshake checks), before they connect.

export const Move = defineInput("game.Move", { x: f32, y: f32, jump: u8 });
Move.write({ x: stick.x, jump: pressed ? 1 : 0 });      // client, in fixedUpdate
const input = Move.of(connection);                       // server, in fixedUpdate
if (input) body.velocity.x = input.x * speed;

Type Parameters

S

S extends Schema

Parameters

id

string

schema

S

options?

InputOptions = {}

Returns

InputDef<S>

Clone this wiki locally