menu_bookDocumentation

Sync Properties: Automatic Property Replication with [Sync] Attribute

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

Adding the [Sync] attribute to a property on a Component will have its latest value sent to other players each time it changes. Only the owner of the object can change sync properties.

CSHARP
public class MyComponent : Component
{
    [Sync] public int Kills { get; set; }
}

Supported Types

[Sync] supports unmanaged types and string. Any value type including structs works: int, bool, Vector3, float. Also supports serializing GameObject, Component, and GameResource.

Detecting Changes

Apply [Change] attribute alongside [Sync] to get a callback when the value changes:

CSHARP
public class MyComponent : Component
{
    [Sync, Change( "OnIsRunningChanged" )] public bool IsRunning { get; set; }

    private void OnIsRunningChanged( bool oldValue, bool newValue )
    {
        // The value of IsRunning has changed
    }
}

SyncFlags

FlagDescription
SyncFlags.QueryValue is checked for changes every network update instead of on set
SyncFlags.FromHostHost has ownership over the value instead of the object owner
SyncFlags.InterpolateValue is interpolated for other clients over a few ticks

Collections

Use NetList<T> and NetDictionary<K,V> for networked collections:

CSHARP
public class MyComponent : Component
{
    [Sync] public NetList&lt;int&gt; List { get; set; } = new();
    [Sync] public NetDictionary&lt;AmmoCount, int&gt; Dictionary { get; set; } = new();
}

Query Mode

Use SyncFlags.Query when the backing field can be modified outside the property setter (e.g., by a separate method). The value is checked for changes every network update rather than relying on setter detection:

CSHARP
Vector3 _velocity;
[Sync( SyncFlags.Query )]
public Vector3 Velocity
{
    get => _velocity;
    set => _velocity = value;
}
Was this helpful?