MultiplayerSynchronizer
Description
Section titled “Description”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 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 Entity 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
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| float | delta_interval |
0.0 |
| bool | public_visibility |
true |
| SceneReplicationConfig | replication_config |
|
| float | replication_interval |
0.0 |
| EntityPath | root_path |
EntityPath("..") |
| VisibilityUpdateMode | visibility_update_mode |
0 |
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| void | add_visibility_filter(filter: Callable) |
| bool | get_visibility_for(peer: int) const |
| void | remove_visibility_filter(filter: Callable) |
| void | set_visibility_for(peer: int, visible: bool) |
| void | update_visibility(for_peer: int = 0) |
Signals
Section titled “Signals”delta_synchronized
delta_synchronized()
Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.
synchronized
synchronized()
Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.
visibility_changed
visibility_changed(for_peer: int)
Emitted when visibility of for_peer is updated. See update_visibility().
Enumerations
Section titled “Enumerations”VisibilityUpdateMode
enum VisibilityUpdateMode
VISIBILITY_PROCESS_IDLE = 0
Visibility filters are updated during process frames (see Entity.NOTIFICATION_INTERNAL_FRAME).
VISIBILITY_PROCESS_PHYSICS = 1
Visibility filters are updated during physics frames (see Entity.NOTIFICATION_INTERNAL_STEP).
VISIBILITY_PROCESS_NONE = 2
Visibility filters are not updated automatically, and must be updated manually by calling update_visibility().
Property descriptions
Section titled “Property descriptions”delta_interval
float delta_interval = 0.0
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.
public_visibility
bool public_visibility = true
Whether synchronization should be visible to all peers by default. See set_visibility_for() and add_visibility_filter() for ways of configuring fine-grained visibility options.
replication_config
SceneReplicationConfig replication_config
Resource containing which properties to synchronize.
replication_interval
float replication_interval = 0.0
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.
root_path
EntityPath root_path = EntityPath("..")
Entity 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.
visibility_update_mode
VisibilityUpdateMode visibility_update_mode = 0
Specifies when visibility filters are updated.
Method descriptions
Section titled “Method descriptions”add_visibility_filter
void add_visibility_filter(filter: Callable)
Adds a peer visibility filter for this synchronizer.
filter should take a peer ID int and return a bool.
get_visibility_for
bool get_visibility_for(peer: int) const
Queries the current visibility for peer peer.
remove_visibility_filter
void remove_visibility_filter(filter: Callable)
Removes a peer visibility filter from this synchronizer.
set_visibility_for
void set_visibility_for(peer: int, visible: bool)
Sets the visibility of peer to visible. If peer is 0, the value of public_visibility will be updated instead.
update_visibility
void update_visibility(for_peer: int = 0)
Updates the visibility of for_peer according to visibility filters. If for_peer is 0 (the default), all peers’ visibilties are updated.
