Class reference

MultiplayerSynchronizer

Inherits Node

Synchronizes properties from the multiplayer authority to the remote peers.

Description

By default, MultiplayerSynchronizer synchronizes configured properties to all peers. Visibility can be handled directly with set_visibility_for() or as-needed with add_visibility_filter() and 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 Object.get_instance_id()) or RIDs, will also not work in synchronization.

Properties

NodePath root_path = NodePath("..")

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.

int visibility_update_mode = 0

Specifies when visibility filters are updated.

Methods

void add_visibility_filter(Callable filter)

Adds a peer visibility filter for this synchronizer. filter should take a peer ID int and return a bool.

bool get_visibility_for(int peer) const

Queries the current visibility for peer peer.

void remove_visibility_filter(Callable filter)

Removes a peer visibility filter from this synchronizer.

void set_visibility_for(int peer, bool visible)

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

void update_visibility(int for_peer = 0)

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

Signals

delta_synchronized()

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

synchronized()

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

Constants

VISIBILITY_PROCESS_NONE = 2

Enum: VisibilityUpdateMode

Visibility filters are not updated automatically, and must be updated manually by calling update_visibility().

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.