MultiplayerSynchronizer

Inherits:Node<Object

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

float

delta_interval

0.0

bool

public_visibility

true

SceneReplicationConfig

replication_config

float

replication_interval

0.0

NodePath

root_path

NodePath("..")

VisibilityUpdateMode

visibility_update_mode

0

Methods

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

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

floatdelta_interval =0.0🔗

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.


boolpublic_visibility =true🔗

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🔗

Resource containing which properties to synchronize.


floatreplication_interval =0.0🔗

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("..")🔗

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🔗

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.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.