Table of Contents

Class MultiplayerSynchronizer

Synchronizes properties from the multiplayer authority to the remote peers.

Inheritance
MultiplayerSynchronizer

Remarks

By default, MultiplayerSynchronizer synchronizes configured properties to all peers.

Visibility can be handled directly with MultiplayerSynchronizer.set_visibility_for or as-needed with MultiplayerSynchronizer.add_visibility_filter and MultiplayerSynchronizer.update_visibility.

MultiplayerSpawners will handle nodes according to visibility of synchronizers as long as the node at root_path was spawned by one.

Internally, MultiplayerSynchronizer uses MultiplayerAPI.object_configuration_add to notify synchronization start passing the Node at root_path as the object and itself as the configuration, and uses MultiplayerAPI.object_configuration_remove to notify synchronization end in a similar way.

Note: Synchronization is not supported for Object type properties, like Resource. Properties that are unique to each peer, like the instance IDs of Objects (see get_instance_id) or RIDs, will also not work in synchronization.

Properties

delta_interval

Time interval between delta synchronizations. Used when the replication is set to SceneReplicationConfig.REPLICATION_MODE_ON_CHANGE. If set to 0.0 (the default), delta synchronizations happen every network process frame.

var delta_interval : float = 0.0

Property Value

float

Remarks

  • void set_delta_interval(float value)
  • float get_delta_interval

public_visibility

Whether synchronization should be visible to all peers by default. See MultiplayerSynchronizer.set_visibility_for and MultiplayerSynchronizer.add_visibility_filter for ways of configuring fine-grained visibility options.

var public_visibility : bool = true

Property Value

bool

Remarks

  • void set_visibility_public(bool value)
  • bool is_visibility_public

replication_config

Resource containing which properties to synchronize.

var replication_config : SceneReplicationConfig

Property Value

SceneReplicationConfig

Remarks

replication_interval

Time interval between synchronizations. Used when the replication is set to SceneReplicationConfig.REPLICATION_MODE_ALWAYS. If set to 0.0 (the default), synchronizations happen every network process frame.

var replication_interval : float = 0.0

Property Value

float

Remarks

  • void set_replication_interval(float value)
  • float get_replication_interval

root_path

Node path that replicated properties are relative to.

If root_path was spawned by a MultiplayerSpawner, the node will be also be spawned and despawned based on this synchronizer visibility options.

var root_path : NodePath = NodePath("..")

Property Value

NodePath

Remarks

visibility_update_mode

Specifies when visibility filters are updated (see VisibilityUpdateMode for options).

var visibility_update_mode : int = 0

Property Value

int

Remarks

  • void set_visibility_update_mode(int value)
  • int get_visibility_update_mode

Methods

add_visibility_filter(Callable)

Adds a peer visibility filter for this synchronizer.

filter should take a peer ID int and return a bool.

void add_visibility_filter(Callable filter)

Parameters

filter Callable

get_visibility_for(int)

Qualifiers: const

Queries the current visibility for peer peer.

bool get_visibility_for(int peer)

Parameters

peer int

remove_visibility_filter(Callable)

Removes a peer visibility filter from this synchronizer.

void remove_visibility_filter(Callable filter)

Parameters

filter Callable

set_visibility_for(int, bool)

Sets the visibility of peer to visible. If peer is 0, the value of public_visibility will be updated instead.

void set_visibility_for(int peer, bool visible)

Parameters

peer int
visible bool

update_visibility(int)

Updates the visibility of for_peer according to visibility filters. If for_peer is 0 (the default), all peers' visibilties are updated.

void update_visibility(int for_peer)

Parameters

for_peer int

Events

delta_synchronized

Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.

signal delta_synchronized

synchronized

Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.

signal synchronized

visibility_changed(int)

Emitted when visibility of for_peer is updated. See MultiplayerSynchronizer.update_visibility.

signal visibility_changed(int for_peer)

Parameters

for_peer int