Skip to content

Engine bindings & SDK surfaces

The flat C ABI is the universal contract. Each engine binding wraps it so it feels native — the wrapper's whole job is to make lattice_* calls look like MonoBehaviours (Unity), UObjects (Unreal), or Nodes (Godot). See design 05 — Engine Integration for the full treatment.

flowchart TD
  ABI["liblattice — extern \"C\" ABI (lattice.h)"]
  ABI -->|P/Invoke + SafeHandle| U["lattice-unity (C#)"]
  ABI -->|direct C++ call| UE["lattice-unreal (UE module)"]
  ABI -->|GDExtension C interface| G["lattice-godot (GDExtension)"]
  ABI -->|Emscripten exports| W["lattice-web (WASM, stretch)"]

Naming

design 05 §2.2 shows a representative sketch using lt_* names. That is illustrative of the binding strategy; the implemented ABI uses the lattice_* names documented throughout this reference. Where they differ, this reference and lattice.h are authoritative.

Unity — lattice-unity (C#, P/Invoke)

Idiomatic API Wraps
NetworkRunner MonoBehaviour, StartGame(GameMode) lattice_runner_create/start/listen/connect, driven from FixedUpdate via lattice_runner_tick
NetworkBehaviour base + [Networked] properties a Roslyn source generator emits the lattice_field_desc schema and mark_dirty calls
[Rpc] methods lattice_rpc + the on_rpc callback
Spawn / Despawn lattice_spawn / lattice_despawn
INetworkInput / OnInput input struct serialized via the bit helpers

Unreal — lattice-unreal

A UE module that calls the C ABI directly and exposes idiomatic UObject replication wrappers (ULatticeRunnerSubsystem, replicated UPROPERTY-style fields mapping to the same field schema, RPC macros over lattice_rpc).

Godot — lattice-godot

A GDExtension exposing a LatticeRunner node and exported networked properties; the GDExtension C interface bridges to the same lattice_* entry points.

Web — lattice-web (stretch)

WASM/Emscripten exports of the binding plus a QUIC/WebTransport backend for the browser.


The managed-sim surface (lattice_managed.h) — write-once / dual-target

For managed WASM hosting the same game-sim source is authored against a narrow, WASM-crossable projection of the full ABI — the managed-sim surface in host/lattice-wasm-host/include/lattice_managed.h. It is a faithful subset reshaped to the lowest common denominator that is identical on native and wasm targets: state lives in the module's memory; everything crosses as scalars or as a (ptr, len) byte blob the host copies immediately; host→module delivery is pulled each tick rather than pushed through a function pointer.

The capability surface (the entire set of things a sandboxed module can do):

lattice_ms_* function Maps to Purpose
lattice_ms_log on_log diagnostics
lattice_ms_register_type_begin / type_field / register_type_end lattice_register_type declare a replicated type
lattice_ms_spawn / lattice_ms_despawn lattice_spawn / lattice_despawn authoritative objects
lattice_ms_get_field_i/f / set_field_i/f lattice_object_state + mark_dirty mutate + replicate fields
lattice_ms_object_count / lattice_ms_object_at object enumeration iterate objects
lattice_ms_rpc lattice_rpc per-object RPC
lattice_ms_send_event / lattice_ms_poll_event lattice_send_event / on_event custom events (pulled)
lattice_ms_http_request / lattice_ms_drain lattice_http_request mediated, egress-gated fetch
lattice_ms_abi_version ABI version handshake
  • Native build: these resolve at link time to the shim in native_host/lattice_ms_native.cpp, which drives a live lattice_runner.
  • WASM build: they are left undefined and the linker emits them as env.lattice_ms_* imports; the managed host is the only thing that satisfies them, so the sandboxed module reaches the core and nothing else.

This is why managed hosting and self-hosting are one source, two link/compile backends, one C-ABI capability surface — see the write-once walkthrough and design 09 — WASM Managed Hosting.


Control-plane SDKs

For account/identity, matchmaking, and social features your client talks to the control-plane HTTP/WebSocket APIs rather than the C ABI. A typed social client (lattice-social-client) wraps the social HTTP + WS protocol.