[Sync] and [Command] Attributes
Sync Attribute
[Sync]
public int health;[Sync("health")]
public float hp;[Sync(DefaultSyncMode = SyncMode.CreationOnly)]
public Color teamColor;SyncMode.Manual
[Sync(DefaultSyncMode = SyncMode.Manual)]
public byte[] playerSettings;
private CoherenceSync coherenceSync;
private ValueBinding<byte[]> settingsBinding;
private void Awake()
{
coherenceSync = GetComponent<CoherenceSync>();
settingsBinding = coherenceSync.GetValueBinding<Player, byte[]>(nameof(playerSettings));
}
public void UpdateSettings(byte[] newSettings)
{
playerSettings = newSettings;
// Manually trigger synchronization when settings change
settingsBinding.MarkForSyncing();
}Switching SyncMode at Runtime
Command Attribute
Command Meta
Last updated
Was this helpful?

