Path: blob/master/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml
10278 views
<?xml version="1.0" encoding="UTF-8" ?>1<class name="MultiplayerSynchronizer" inherits="Node" keywords="network" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">2<brief_description>3Synchronizes properties from the multiplayer authority to the remote peers.4</brief_description>5<description>6By default, [MultiplayerSynchronizer] synchronizes configured properties to all peers.7Visibility can be handled directly with [method set_visibility_for] or as-needed with [method add_visibility_filter] and [method update_visibility].8[MultiplayerSpawner]s will handle nodes according to visibility of synchronizers as long as the node at [member root_path] was spawned by one.9Internally, [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.10[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.11</description>12<tutorials>13</tutorials>14<methods>15<method name="add_visibility_filter">16<return type="void" />17<param index="0" name="filter" type="Callable" />18<description>19Adds a peer visibility filter for this synchronizer.20[param filter] should take a peer ID [int] and return a [bool].21</description>22</method>23<method name="get_visibility_for" qualifiers="const">24<return type="bool" />25<param index="0" name="peer" type="int" />26<description>27Queries the current visibility for peer [param peer].28</description>29</method>30<method name="remove_visibility_filter">31<return type="void" />32<param index="0" name="filter" type="Callable" />33<description>34Removes a peer visibility filter from this synchronizer.35</description>36</method>37<method name="set_visibility_for">38<return type="void" />39<param index="0" name="peer" type="int" />40<param index="1" name="visible" type="bool" />41<description>42Sets 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.43</description>44</method>45<method name="update_visibility">46<return type="void" />47<param index="0" name="for_peer" type="int" default="0" />48<description>49Updates 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.50</description>51</method>52</methods>53<members>54<member name="delta_interval" type="float" setter="set_delta_interval" getter="get_delta_interval" default="0.0">55Time interval between delta synchronizations. Used when the replication is set to [constant SceneReplicationConfig.REPLICATION_MODE_ON_CHANGE]. If set to [code]0.0[/code] (the default), delta synchronizations happen every network process frame.56</member>57<member name="public_visibility" type="bool" setter="set_visibility_public" getter="is_visibility_public" default="true">58Whether 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.59</member>60<member name="replication_config" type="SceneReplicationConfig" setter="set_replication_config" getter="get_replication_config">61Resource containing which properties to synchronize.62</member>63<member name="replication_interval" type="float" setter="set_replication_interval" getter="get_replication_interval" default="0.0">64Time interval between synchronizations. Used when the replication is set to [constant SceneReplicationConfig.REPLICATION_MODE_ALWAYS]. If set to [code]0.0[/code] (the default), synchronizations happen every network process frame.65</member>66<member name="root_path" type="NodePath" setter="set_root_path" getter="get_root_path" default="NodePath("..")">67Node path that replicated properties are relative to.68If [member root_path] was spawned by a [MultiplayerSpawner], the node will be also be spawned and despawned based on this synchronizer visibility options.69</member>70<member name="visibility_update_mode" type="int" setter="set_visibility_update_mode" getter="get_visibility_update_mode" enum="MultiplayerSynchronizer.VisibilityUpdateMode" default="0">71Specifies when visibility filters are updated.72</member>73</members>74<signals>75<signal name="delta_synchronized">76<description>77Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.78</description>79</signal>80<signal name="synchronized">81<description>82Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.83</description>84</signal>85<signal name="visibility_changed">86<param index="0" name="for_peer" type="int" />87<description>88Emitted when visibility of [param for_peer] is updated. See [method update_visibility].89</description>90</signal>91</signals>92<constants>93<constant name="VISIBILITY_PROCESS_IDLE" value="0" enum="VisibilityUpdateMode">94Visibility filters are updated during process frames (see [constant Node.NOTIFICATION_INTERNAL_PROCESS]).95</constant>96<constant name="VISIBILITY_PROCESS_PHYSICS" value="1" enum="VisibilityUpdateMode">97Visibility filters are updated during physics frames (see [constant Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS]).98</constant>99<constant name="VISIBILITY_PROCESS_NONE" value="2" enum="VisibilityUpdateMode">100Visibility filters are not updated automatically, and must be updated manually by calling [method update_visibility].101</constant>102</constants>103</class>104105106