MultiplayerSynchronizer
Synchronizes properties from the multiplayer authority to the remote peers.
Synchronizes properties from the multiplayer authority to the remote peers.
By default, MultiplayerSynchronizer synchronizes configured properties to all peers.
Visibility can be handled directly with MultiplayerSynchronizer.SetVisibilityFor or as-needed with MultiplayerSynchronizer.AddVisibilityFilter and MultiplayerSynchronizer.UpdateVisibility.
MultiplayerSpawners will handle nodes according to visibility of synchronizers as long as the node at MultiplayerSynchronizer.RootPath was spawned by one.
Internally, MultiplayerSynchronizer uses MultiplayerApi.ObjectConfigurationAdd to notify synchronization start passing the Entity at MultiplayerSynchronizer.RootPath as the object and itself as the configuration, and uses MultiplayerApi.ObjectConfigurationRemove to notify synchronization end in a similar way.
Note: Synchronization is not supported for ReckfellObject type properties, like Resource. Properties that are unique to each peer, like the instance IDs of ReckfellObjects (see ReckfellObject.GetInstanceId) or Rids, will also not work in synchronization.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
MultiplayerSynchronizerConstructor
public MultiplayerSynchronizer();Properties6
DeltaIntervalProperty
public double DeltaInterval { get; set; }Time interval between delta synchronizations. Used when the replication is set to SceneReplicationConfig.ReplicationMode.OnChange. If set to 0.0 (the default), delta synchronizations happen every network process frame.
PublicVisibilityProperty
public bool PublicVisibility { get; set; }Whether synchronization should be visible to all peers by default. See MultiplayerSynchronizer.SetVisibilityFor and MultiplayerSynchronizer.AddVisibilityFilter for ways of configuring fine-grained visibility options.
ReplicationConfigProperty
public SceneReplicationConfig ReplicationConfig { get; set; }Resource containing which properties to synchronize.
ReplicationIntervalProperty
public double ReplicationInterval { get; set; }Time interval between synchronizations. Used when the replication is set to SceneReplicationConfig.ReplicationMode.Always. If set to 0.0 (the default), synchronizations happen every network process frame.
RootPathProperty
public EntityPath RootPath { get; set; }Entity path that replicated properties are relative to.
If MultiplayerSynchronizer.RootPath was spawned by a MultiplayerSpawner, the node will be also be spawned and despawned based on this synchronizer visibility options.
VisibilityUpdateModeProperty
public MultiplayerSynchronizer.VisibilityUpdateModeEnum VisibilityUpdateMode { get; set; }Specifies when visibility filters are updated.
Methods17
AddVisibilityFiltervoid
public void AddVisibilityFilter(Callable filter);Adds a peer visibility filter for this synchronizer.
filter should take a peer ID [int] and return a [bool].
| Name | Type | Default |
|---|---|---|
filter | Callable | — |
GetDeltaIntervaldouble
public double GetDeltaInterval();doubleGetReplicationConfigSceneReplicationConfig
public SceneReplicationConfig GetReplicationConfig();SceneReplicationConfigGetReplicationIntervaldouble
public double GetReplicationInterval();doubleGetRootPathEntityPath
public EntityPath GetRootPath();EntityPathGetVisibilityForbool
public bool GetVisibilityFor(int peer);Queries the current visibility for peer peer.
| Name | Type | Default |
|---|---|---|
peer | int | — |
boolGetVisibilityUpdateModeMultiplayerSynchronizer.VisibilityUpdateModeEnum
public MultiplayerSynchronizer.VisibilityUpdateModeEnum GetVisibilityUpdateMode();MultiplayerSynchronizer.VisibilityUpdateModeEnumIsVisibilityPublicbool
public bool IsVisibilityPublic();boolRemoveVisibilityFiltervoid
public void RemoveVisibilityFilter(Callable filter);Removes a peer visibility filter from this synchronizer.
| Name | Type | Default |
|---|---|---|
filter | Callable | — |
SetDeltaIntervalvoid
public void SetDeltaInterval(double milliseconds);| Name | Type | Default |
|---|---|---|
milliseconds | double | — |
SetReplicationConfigvoid
public void SetReplicationConfig(SceneReplicationConfig config);| Name | Type | Default |
|---|---|---|
config | SceneReplicationConfig | — |
SetReplicationIntervalvoid
public void SetReplicationInterval(double milliseconds);| Name | Type | Default |
|---|---|---|
milliseconds | double | — |
SetRootPathvoid
public void SetRootPath(EntityPath path);| Name | Type | Default |
|---|---|---|
path | EntityPath | — |
SetVisibilityForvoid
public void SetVisibilityFor(int peer, bool visible);Sets the visibility of peer to visible. If peer is 0, the value of MultiplayerSynchronizer.PublicVisibility will be updated instead.
| Name | Type | Default |
|---|---|---|
peer | int | — |
visible | bool | — |
SetVisibilityPublicvoid
public void SetVisibilityPublic(bool visible);| Name | Type | Default |
|---|---|---|
visible | bool | — |
SetVisibilityUpdateModevoid
public void SetVisibilityUpdateMode(MultiplayerSynchronizer.VisibilityUpdateModeEnum mode);| Name | Type | Default |
|---|---|---|
mode | MultiplayerSynchronizer.VisibilityUpdateModeEnum | — |
UpdateVisibilityvoid
public void UpdateVisibility(int forPeer = 0);Updates the visibility of for_peer according to visibility filters. If for_peer is 0 (the default), all peers' visibilties are updated.
| Name | Type | Default |
|---|---|---|
forPeer | int | 0 |
Signals and events3
DeltaSynchronizedEvent
public event Action DeltaSynchronized;Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.
SynchronizedEvent
public event Action Synchronized;Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.
VisibilityChangedEvent
public event MultiplayerSynchronizer.VisibilityChangedEventHandler VisibilityChanged;Emitted when visibility of for_peer is updated. See MultiplayerSynchronizer.UpdateVisibility.
| Name | Type | Default |
|---|---|---|
forPeer | long | — |
MultiplayerSynchronizer.VisibilityUpdateModeEnum
| Value | Description |
|---|---|
Idle = 0 | Visibility filters are updated during process frames (see |
None = 2 | Visibility filters are not updated automatically, and must be updated manually by calling |
Physics = 1 | Visibility filters are updated during physics frames (see |