MultiplayerSynchronizer
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 withset_visibility_for() or as-needed withadd_visibility_filter() andupdate_visibility().
MultiplayerSpawners will handle nodes according to visibility of synchronizers as long as the node atroot_path was spawned by one.
Internally,MultiplayerSynchronizer usesMultiplayerAPI.object_configuration_add() to notify synchronization start passing theNode atroot_path as theobject
and itself as theconfiguration
, and usesMultiplayerAPI.object_configuration_remove() to notify synchronization end in a similar way.
Note: Synchronization is not supported forObject type properties, likeResource. Properties that are unique to each peer, like the instance IDs ofObjects (seeObject.get_instance_id()) orRIDs, will also not work in synchronization.
Properties
| ||
| ||
| ||
| ||
|
Methods
add_visibility_filter(filter:Callable) | |
get_visibility_for(peer:int)const | |
remove_visibility_filter(filter:Callable) | |
set_visibility_for(peer:int, visible:bool) | |
update_visibility(for_peer:int = 0) |
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.
visibility_changed(for_peer:int)🔗
Emitted when visibility offor_peer
is updated. Seeupdate_visibility().
Enumerations
enumVisibilityUpdateMode:🔗
VisibilityUpdateModeVISIBILITY_PROCESS_IDLE =0
Visibility filters are updated during process frames (seeNode.NOTIFICATION_INTERNAL_PROCESS).
VisibilityUpdateModeVISIBILITY_PROCESS_PHYSICS =1
Visibility filters are updated during physics frames (seeNode.NOTIFICATION_INTERNAL_PHYSICS_PROCESS).
VisibilityUpdateModeVISIBILITY_PROCESS_NONE =2
Visibility filters are not updated automatically, and must be updated manually by callingupdate_visibility().
Property Descriptions
floatget_delta_interval()
Time interval between delta synchronizations. Used when the replication is set toSceneReplicationConfig.REPLICATION_MODE_ON_CHANGE. If set to0.0
(the default), delta synchronizations happen every network process frame.
boolis_visibility_public()
Whether synchronization should be visible to all peers by default. Seeset_visibility_for() andadd_visibility_filter() for ways of configuring fine-grained visibility options.
SceneReplicationConfigreplication_config🔗
SceneReplicationConfigget_replication_config()
Resource containing which properties to synchronize.
floatreplication_interval =0.0
🔗
floatget_replication_interval()
Time interval between synchronizations. Used when the replication is set toSceneReplicationConfig.REPLICATION_MODE_ALWAYS. If set to0.0
(the default), synchronizations happen every network process frame.
NodePathroot_path =NodePath("..")
🔗
NodePathget_root_path()
Node path that replicated properties are relative to.
Ifroot_path was spawned by aMultiplayerSpawner, the node will be also be spawned and despawned based on this synchronizer visibility options.
VisibilityUpdateModevisibility_update_mode =0
🔗
VisibilityUpdateModeget_visibility_update_mode()
Specifies when visibility filters are updated (seeVisibilityUpdateMode for options).
Method Descriptions
voidadd_visibility_filter(filter:Callable)🔗
Adds a peer visibility filter for this synchronizer.
filter
should take a peer IDint and return abool.
boolget_visibility_for(peer:int)const🔗
Queries the current visibility for peerpeer
.
voidremove_visibility_filter(filter:Callable)🔗
Removes a peer visibility filter from this synchronizer.
voidset_visibility_for(peer:int, visible:bool)🔗
Sets the visibility ofpeer
tovisible
. Ifpeer
is0
, the value ofpublic_visibility will be updated instead.
voidupdate_visibility(for_peer:int = 0)🔗
Updates the visibility offor_peer
according to visibility filters. Iffor_peer
is0
(the default), all peers' visibilties are updated.