2021-10-08 14:13:06 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2024-02-21 18:51:08 +01:00
<class name= "MultiplayerSynchronizer" inherits= "Node" keywords= "network" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../../../doc/class.xsd" >
2021-10-08 14:13:06 +02:00
<brief_description >
2022-07-29 01:30:30 +02:00
Synchronizes properties from the multiplayer authority to the remote peers.
2021-10-08 14:13:06 +02:00
</brief_description>
<description >
2022-07-29 01:30:30 +02:00
By default, [MultiplayerSynchronizer] synchronizes configured properties to all peers.
2022-09-30 14:23:36 +02:00
Visibility can be handled directly with [method set_visibility_for] or as-needed with [method add_visibility_filter] and [method update_visibility].
2022-07-29 01:30:30 +02:00
[MultiplayerSpawner]s will handle nodes according to visibility of synchronizers as long as the node at [member root_path] was spawned by one.
Internally, [MultiplayerSynchronizer] uses [method MultiplayerAPI.object_configuration_add] to notify synchronization start passing the [Node] at [member root_path] as the [code]object[/code] and itself as the [code]configuration[/code], and uses [method MultiplayerAPI.object_configuration_remove] to notify synchronization end in a similar way.
2023-03-04 11:37:02 +01:00
[b]Note:[/b] Synchronization is not supported for [Object] type properties, like [Resource]. Properties that are unique to each peer, like the instance IDs of [Object]s (see [method Object.get_instance_id]) or [RID]s, will also not work in synchronization.
2021-10-08 14:13:06 +02:00
</description>
<tutorials >
</tutorials>
2022-07-09 20:45:30 +02:00
<methods >
<method name= "add_visibility_filter" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "filter" type= "Callable" />
2022-07-09 20:45:30 +02:00
<description >
2022-07-29 01:30:30 +02:00
Adds a peer visibility filter for this synchronizer.
2023-04-26 21:36:04 +02:00
[param filter] should take a peer ID [int] and return a [bool].
2022-07-09 20:45:30 +02:00
</description>
</method>
<method name= "get_visibility_for" qualifiers= "const" >
<return type= "bool" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "peer" type= "int" />
2022-07-09 20:45:30 +02:00
<description >
2023-04-26 21:36:04 +02:00
Queries the current visibility for peer [param peer].
2022-07-09 20:45:30 +02:00
</description>
</method>
<method name= "remove_visibility_filter" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "filter" type= "Callable" />
2022-07-09 20:45:30 +02:00
<description >
2022-09-30 14:23:36 +02:00
Removes a peer visibility filter from this synchronizer.
2022-07-09 20:45:30 +02:00
</description>
</method>
<method name= "set_visibility_for" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "peer" type= "int" />
<param index= "1" name= "visible" type= "bool" />
2022-07-09 20:45:30 +02:00
<description >
2023-04-26 21:36:04 +02:00
Sets the visibility of [param peer] to [param visible]. If [param peer] is [code]0[/code], the value of [member public_visibility] will be updated instead.
2022-07-09 20:45:30 +02:00
</description>
</method>
<method name= "update_visibility" >
<return type= "void" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "for_peer" type= "int" default= "0" />
2022-07-09 20:45:30 +02:00
<description >
2023-04-26 21:36:04 +02:00
Updates the visibility of [param for_peer] according to visibility filters. If [param for_peer] is [code]0[/code] (the default), all peers' visibilties are updated.
2022-07-09 20:45:30 +02:00
</description>
</method>
</methods>
2021-10-08 14:13:06 +02:00
<members >
2023-03-28 09:30:58 +02:00
<member name= "delta_interval" type= "float" setter= "set_delta_interval" getter= "get_delta_interval" default= "0.0" >
Time interval between delta synchronizations. When set to [code]0.0[/code] (the default), delta synchronizations happen every network process frame.
</member>
2022-07-09 20:45:30 +02:00
<member name= "public_visibility" type= "bool" setter= "set_visibility_public" getter= "is_visibility_public" default= "true" >
2022-07-29 01:30:30 +02:00
Whether synchronization should be visible to all peers by default. See [method set_visibility_for] and [method add_visibility_filter] for ways of configuring fine-grained visibility options.
2022-07-09 20:45:30 +02:00
</member>
2022-05-24 08:31:44 +02:00
<member name= "replication_config" type= "SceneReplicationConfig" setter= "set_replication_config" getter= "get_replication_config" >
2022-07-29 01:30:30 +02:00
Resource containing which properties to synchronize.
2021-10-08 14:13:06 +02:00
</member>
2022-05-23 02:24:14 +02:00
<member name= "replication_interval" type= "float" setter= "set_replication_interval" getter= "get_replication_interval" default= "0.0" >
2023-03-28 09:30:58 +02:00
Time interval between synchronizations. When set to [code]0.0[/code] (the default), synchronizations happen every network process frame.
2021-10-08 14:13:06 +02:00
</member>
2022-05-23 02:24:14 +02:00
<member name= "root_path" type= "NodePath" setter= "set_root_path" getter= "get_root_path" default= "NodePath("..")" >
2022-07-29 01:30:30 +02:00
Node path that replicated properties are relative to.
If [member root_path] was spawned by a [MultiplayerSpawner], the node will be also be spawned and despawned based on this synchronizer visibility options.
2021-10-08 14:13:06 +02:00
</member>
2022-07-09 20:45:30 +02:00
<member name= "visibility_update_mode" type= "int" setter= "set_visibility_update_mode" getter= "get_visibility_update_mode" enum= "MultiplayerSynchronizer.VisibilityUpdateMode" default= "0" >
2022-07-29 01:30:30 +02:00
Specifies when visibility filters are updated (see [enum VisibilityUpdateMode] for options).
2022-07-09 20:45:30 +02:00
</member>
2021-10-08 14:13:06 +02:00
</members>
2022-07-09 20:45:30 +02:00
<signals >
2023-03-28 09:30:58 +02:00
<signal name= "delta_synchronized" >
<description >
Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.
</description>
</signal>
2023-02-20 14:46:39 +01:00
<signal name= "synchronized" >
<description >
2023-03-28 09:30:58 +02:00
Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.
2023-02-20 14:46:39 +01:00
</description>
</signal>
2022-07-09 20:45:30 +02:00
<signal name= "visibility_changed" >
2022-08-06 20:11:48 +02:00
<param index= "0" name= "for_peer" type= "int" />
2022-07-09 20:45:30 +02:00
<description >
2023-04-26 21:36:04 +02:00
Emitted when visibility of [param for_peer] is updated. See [method update_visibility].
2022-07-09 20:45:30 +02:00
</description>
</signal>
</signals>
<constants >
<constant name= "VISIBILITY_PROCESS_IDLE" value= "0" enum= "VisibilityUpdateMode" >
2023-06-01 01:38:19 +02:00
Visibility filters are updated during process frames (see [constant Node.NOTIFICATION_INTERNAL_PROCESS]).
2022-07-09 20:45:30 +02:00
</constant>
<constant name= "VISIBILITY_PROCESS_PHYSICS" value= "1" enum= "VisibilityUpdateMode" >
2023-06-01 01:38:19 +02:00
Visibility filters are updated during physics frames (see [constant Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS]).
2022-07-09 20:45:30 +02:00
</constant>
<constant name= "VISIBILITY_PROCESS_NONE" value= "2" enum= "VisibilityUpdateMode" >
2022-07-29 01:30:30 +02:00
Visibility filters are not updated automatically, and must be updated manually by calling [method update_visibility].
2022-07-09 20:45:30 +02:00
</constant>
</constants>
2021-10-08 14:13:06 +02:00
</class>