For the complete documentation index, see llms.txt. This page is also available as Markdown.

Automatic Client Data Syncing

Summary

How server state reaches clients: properties, transforms, sync groups for visibility, and the client prediction that keeps it smooth. It is part of the Reactor Technical Overview.

Properties

Properties are one way state syncs. A property is a value keyed by a numeric id, attached to a room, player, or entity. Property values use ksMultiType, which has implicit conversions to and from many basic data types and their arrays, so you read and write with plain C# types:

// Server, or a client that owns the entity with PROPERTIES permission
entity.Properties[Prop.SCORE] = 10;

// Anywhere
int score = entity.Properties[Prop.SCORE];

The server tracks which properties changed and sends only those on the next sync, not the whole set. On the client, a property change raises an event you can handle:

entity.OnPropertyChange[Prop.SCORE] += (oldValue, newValue) => { /* react */ };

Transforms

An entity's transform syncs the same way. Set position, rotation, and scale on the server through entity.Transform (or entity.Transform2D), and the client receives them. On the client, entity.Transform gives the smoothed value the game renders, while entity.ServerTransform gives the raw server value.

Precision is configurable per entity as a quantization step. A larger step sends fewer, smaller updates; a step of 0 keeps full precision. A teleport flag marks a discrete jump so the client snaps to it instead of interpolating.

Sync Groups

Sync groups control which entities a player receives, so a large world does not send every object to every client. An entity belongs to a single sync group, while a player can be added to many sync groups at once. Group 0 is the default for entities, and every player is in it. For any other group, a player receives its entities only after being added to it:

Removing a player from a group destroys those entities on that client, and the client's entity destroy event carries a reason of ksDestroyReason.SYNC_GROUP_REMOVAL. Sync groups are Reactor's interest-management tool. See Interest Management via Sync Groups.

Client Prediction

State arrives less often than the client renders. Predictors decide how an entity moves between server updates. Assign one per entity to match how it behaves:

  • ksLinearPredictor: blends toward each new server transform. The default, suited to entities the local player does not control.

  • ksClientInputPredictor: drives the entity from local input and ignores server transforms. Needs a controller.

  • ksConvergingInputPredictor: predicts from local input, then eases toward the server's authoritative position as updates arrive. Needs a controller.

Can be assigned in code with entity.NonInputPredictor or entity.InputPredictor, and configure smoothing rates on the predictor. Predictors can also be assigned per entity in the ksEntityComponent, or as a default for all entities in the ksRoomType component. Prediction changes how an entity looks between updates, not what the server decides, so the visible state converges back to the server's truth. See Motion Prediction.

On the client, a property or transform can carry both a predicted display value and the raw server value. Read the server value when you need the authoritative number rather than the smoothed one.

Where to Go Next

Last updated