LogoLogo
⚠️ Outdated documentationGo to LatestHomeAPI
SDK 1.0
SDK 1.0
  • Welcome
  • Overview
    • What is coherence?
    • How does coherence work?
    • Rooms and Worlds
    • Features and Roadmap
    • Release Notes
    • Known Issues and Troubleshooting
  • Learning coherence
    • Beginner's Guide to Networking Games
    • First Steps tutorial
      • 1. Basic syncing
        • 1.2. Animation parameters
        • 1.3. Sending commands
      • 2. Physics / Authority transfer
      • 3. Areas of interest
      • 4. Parenting entities
      • 5. Complex hierarchies
      • 6. Persistence
    • Campfire project
      • Game mechanics
      • Leveraging object pooling
      • Remote interactions: Chairs
      • Remote interactions: Trees
      • A unique object with complex state
      • Custom instantiation and destruction
      • Running a server-side NPC
      • Playing audio and particles
      • A simple text chat
    • How to network...
      • Racing
      • Turn-based
      • First-Person Shooter
      • MMO
      • Fighting
  • Get started
    • Installation
    • Scene Setup
      • Samples
    • Prefab Setup: CoherenceSync
    • Local Development
      • Tips and Recommendations
    • coherence Cloud
      • Create a Free Account
      • Deploy a Replication Server
      • Share Builds
  • coherence SDK for Unity
    • Components
      • CoherenceSync
      • CoherenceBridge
      • CoherenceLiveQuery
      • CoherenceTagQuery
      • Order of execution
    • Asset Management
      • Using CoherenceSyncConfig to instantiate GameObjects locally
      • CoherenceSyncConfigRegistry Save Modes
    • Networking State Changes
      • Messaging with Commands
      • Hierarchies & Child Objects
        • Child GameObjects
        • Child CoherenceSyncs
        • Deep Child CoherenceSyncs
      • Animations
      • CoherenceSync References
      • [Sync] and [Command] Attributes
      • [OnValueSynced] Attribute
      • Supported Types
      • Creating your own syncable member
    • Baking (Code Generation)
    • Scene Management
    • Authority
      • Authority transfer
      • Server-authoritative setup
    • Lifetime
      • Persistence
      • Example – a global counter
    • Optimization
      • Simulation Frequency
      • Areas of Interest
      • Level of Detail (LOD)
    • Profiling
    • Interpolation
    • Rigid Bodies
    • Settings
    • Simulation Frame
    • Replication Server
    • Simulators
      • Scripting: Client vs Simulator
      • Local Development
      • World Simulators
      • Room Simulators
      • Simulator Slugs
      • Multi-Room Simulators
      • Build and Publish
      • Command-line arguments
      • Load Balancing
    • Client-Hosting
    • Client Connections
    • Rollback Networking Support
    • World Origin Shifting
    • CLI
    • Upgrading Unity SDK
      • Upgrading to coherence Unity SDK 1.0.0
      • Upgrading to coherence Unity SDK 0.9.0
  • coherence Cloud
    • Developer Portal
    • Dashboard
    • Worlds
    • Rooms
    • Lobbies
    • Game Services
      • Account
      • Key-Value Store
    • Using coherence Cloud in Unity
      • Worlds
      • Rooms
      • Lobbies
      • Game Services
        • Authentication Service (Player Accounts)
        • Key-value store
  • Schema explained
    • Overview
    • Specification
    • Field settings
    • Archetypes
  • coherence Scripting API
  • Additional resources
    • Community
    • Quick Samples
    • Continuous Integration
    • Unreal Engine Support
    • WebGL Support
    • Peer-to-Peer Support (P2P)
    • Pricing
    • SLA
    • Glossary
Powered by GitBook
On this page
  • Primitive Types
  • Field Settings
  • Components
  • Built-in components
  • Archetypes
  • Commands
  • Inputs
  • Limits

Was this helpful?

Export as PDF
  1. Schema explained

Specification

Primitive Types

These are the primitive types supported in a coherence schema:

Int

Uses a default range of -2147483648 to 2147483647 (32 bits).

UInt

Uses the default range of 0 to 4294967295 (32 bits).

Int64

Uses the default range of -9223372036854775808 to 9223372036854775807 (64 bits).

UInt64

Uses the default range of 0 to 18446744073709551615 (64 bits).

Float

Encoded using one of the following compression types: None, Truncated, FixedPoint (defaults to None).

Float64

Higher precision floating point using 64 bits. It does not support compression.

Bool

Encoded using a single bit.

Vector2

Encoded using two floats with a specified compression (defaults to None).

Vector3

Encoded using three floats with a specified compression (defaults to None).

Quaternion

Encoded using three components and a sign bit.

Color

Encoded using four components (RGBA).

String

A string with up to 63 bytes encoded using 6 bits for length.

Bytes

An array of bytes with an upper limit of 511 bytes encoded using 9 bits for length.

Packet fragmentation is not supported yet in this version, so packets bigger than the internal MTU (~1200 bytes) may be never sent.

Entity

The Entity type is used to keep references to other Entities. Technically the reference is stored as a local index that has to be resolved to an actual Entity before usage. Also, since a Client might not know about the referenced Entity (due to it being outside of its LiveQuery) an Entity reference might be impossible to resolve in some circumstances. Your Client code will have to take this into account and be programmed in a defensive way that handles missing Entities gracefully.

Field Settings

Components

The most common definition in schemas is components, which correspond to replicated fields for baked MonoBehaviours.

The definition takes a name of the component, and on the following lines an indented list of member variables, each one followed by their primitive type (see above.) The indentation has to be exactly 2 spaces. Here's how it might look:

component Portal
  locked Bool
  connectedTo Entity
  size Float

After code generation, this will give access to a component with the name Portal that has the members locked, connectedTo, and size.

Optionally, each member/type pair can have additional meta data listed on the same line, using the following syntax:

[key1 "value1", key2 "value", etc...]

This is how it might look in an actual example:

component Portal
  locked Bool 
  connectedTo Entity [prio "high"]
  size Float [prio "low", bits "16"]

Built-in components

There are some components that are built into the Protocol Code Generator and that you will always have access to.

Archetypes

Commands

Commands are defined very similarly to components, but they use the command keyword instead.

Here's a simple example of a command:

command Damage [routing "AuthorityOnly"]
  amount Int
  explosive Bool

Routing defines to whom the command can be sent. Currently, two values are supported:

  • AuthorityOnly - command will be received only by the owner of the target Entity

  • All - command will be received by every Client that has a copy of this Entity

Inputs

Inputs represent a group of values that are snapshotted every frame (or fixed frame). This snapshot is then sent to other clients or a session host, so it can be processed by the same code on both ends, resulting in the same outcome.

Example of an input:

input PlayerInput
  XMov Vector2 [compression "None"]
  YMov Vector2 [compression "None"]
  Jump Bool
  Shoot Bool
  Throttle Float [compression "None"]
  Command String

Limits

Schemas have limits to protect the Replication Server. Ensure you stay within these limits:

  • A single schema cannot have more than 10 million characters

  • A component/command name cannot be more than 512 characters

  • A field/archetype/input/enum name cannot be longer than 128 characters

  • A component cannot have more than 128 fields

Last updated 2 years ago

Was this helpful?

Several of the primitive types can be configured to take up less space when sent over the network, see .

Archetypes are used to optimize the sending of data from the Server to each Client, lowering the precision or even turning off whole components based on the distance from the LiveQuery to a particular Entity. Read more about how to define them in the schema on the page .

When using reflection, there are limitations to what types are supported in commands. See the section for more information.

Field settings
Archetypes and LOD-ing
Supported types in commands