The Data Model

Your network data model is a Schema. You edit it as forms in the Netcode tool, and the tool writes the .netschema file. Netcode Foundation is version 0.1.0, an early release. Interfaces, the Schema format and the wire format may change before 1.0.

Create a Schema #

  1. Choose Tools, Netcode.
  2. Use New Schema… on the toolbar and save it in your project.
  3. On the Types page, add a type, for example Crate.
  4. Add fields to it.

The Asset Processor copies .netschema and .netaccess files into product assets, so the game can load them at run time. A Schema can only be changed when no session is running.

Types and fields #

Each type is a card on the Types page. A field’s kind is a drop-down, and you declare what the data means rather than how it is stored.

KindOptions
Yes or noA boolean.
NumberA minimum, maximum and decimal places. The build chooses the smallest unit that holds the range.
Text, BytesA maximum length.
NetRecord reference, ConnectionA reference to another NetRecord, or to a connection.
CollectionsUp to a stated count, held in a paged pool.
StructsReusable groups of fields, defined on their own card.

Beside each field you also choose who writes it (the Any Server by default, or the owner), its sync profile, and the aspects and levels that control who may hold it. “Add a pose…” adds the fields a transform sync needs.

Messages and network settings #

Messages, structs and the network settings (stages, profiles, aspects) each have their own card. See Values and Messages for messages.

The file #

Nobody has to read it, but it is plain JSON and good for source control. The top level holds format, layout, name, levelBits, maxConnections, tickRate, compatibleHashes, rpcs, aspects, stages, profiles, structs and types. A type holds a name, a kind, player, observed, retained and its fields. The Arena sample’s arena.netschema is a worked example. The Schema format may change before 1.0.

Loading a Schema #

Set /Heathen/Netcode/SchemaPath to the product path, or /Heathen/Netcode/SchemaFile to a path on disk, or load it from script before a session starts.

NetcodeRequestBus.Broadcast.LoadSchema("netcode/game.netschema")

A Schema is required before a NetRecord can exist. C++ projects can build one in code with SchemaBuilder instead.

Next: Binding to Game Objects.

Rate This Article!