class_multiplayersynchronizer.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/modules/multiplayer/doc_classes/MultiplayerSynchronizer.xml.
  6. .. _class_MultiplayerSynchronizer:
  7. MultiplayerSynchronizer
  8. =======================
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Synchronizes properties from the multiplayer authority to the remote peers.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. By default, **MultiplayerSynchronizer** synchronizes configured properties to all peers.
  15. Visibility can be handled directly with :ref:`set_visibility_for<class_MultiplayerSynchronizer_method_set_visibility_for>` or as-needed with :ref:`add_visibility_filter<class_MultiplayerSynchronizer_method_add_visibility_filter>` and :ref:`update_visibility<class_MultiplayerSynchronizer_method_update_visibility>`.
  16. \ :ref:`MultiplayerSpawner<class_MultiplayerSpawner>`\ s will handle nodes according to visibility of synchronizers as long as the node at :ref:`root_path<class_MultiplayerSynchronizer_property_root_path>` was spawned by one.
  17. Internally, **MultiplayerSynchronizer** uses :ref:`MultiplayerAPI.object_configuration_add<class_MultiplayerAPI_method_object_configuration_add>` to notify synchronization start passing the :ref:`Node<class_Node>` at :ref:`root_path<class_MultiplayerSynchronizer_property_root_path>` as the ``object`` and itself as the ``configuration``, and uses :ref:`MultiplayerAPI.object_configuration_remove<class_MultiplayerAPI_method_object_configuration_remove>` to notify synchronization end in a similar way.
  18. \ **Note:** Synchronization is not supported for :ref:`Object<class_Object>` type properties, like :ref:`Resource<class_Resource>`. Properties that are unique to each peer, like the instance IDs of :ref:`Object<class_Object>`\ s (see :ref:`Object.get_instance_id<class_Object_method_get_instance_id>`) or :ref:`RID<class_RID>`\ s, will also not work in synchronization.
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  25. | :ref:`float<class_float>` | :ref:`delta_interval<class_MultiplayerSynchronizer_property_delta_interval>` | ``0.0`` |
  26. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  27. | :ref:`bool<class_bool>` | :ref:`public_visibility<class_MultiplayerSynchronizer_property_public_visibility>` | ``true`` |
  28. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  29. | :ref:`SceneReplicationConfig<class_SceneReplicationConfig>` | :ref:`replication_config<class_MultiplayerSynchronizer_property_replication_config>` | |
  30. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  31. | :ref:`float<class_float>` | :ref:`replication_interval<class_MultiplayerSynchronizer_property_replication_interval>` | ``0.0`` |
  32. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  33. | :ref:`NodePath<class_NodePath>` | :ref:`root_path<class_MultiplayerSynchronizer_property_root_path>` | ``NodePath("..")`` |
  34. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  35. | :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` | :ref:`visibility_update_mode<class_MultiplayerSynchronizer_property_visibility_update_mode>` | ``0`` |
  36. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  37. .. rst-class:: classref-reftable-group
  38. Methods
  39. -------
  40. .. table::
  41. :widths: auto
  42. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`add_visibility_filter<class_MultiplayerSynchronizer_method_add_visibility_filter>` **(** :ref:`Callable<class_Callable>` filter **)** |
  44. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`get_visibility_for<class_MultiplayerSynchronizer_method_get_visibility_for>` **(** :ref:`int<class_int>` peer **)** |const| |
  46. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`remove_visibility_filter<class_MultiplayerSynchronizer_method_remove_visibility_filter>` **(** :ref:`Callable<class_Callable>` filter **)** |
  48. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_visibility_for<class_MultiplayerSynchronizer_method_set_visibility_for>` **(** :ref:`int<class_int>` peer, :ref:`bool<class_bool>` visible **)** |
  50. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`update_visibility<class_MultiplayerSynchronizer_method_update_visibility>` **(** :ref:`int<class_int>` for_peer=0 **)** |
  52. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. .. rst-class:: classref-section-separator
  54. ----
  55. .. rst-class:: classref-descriptions-group
  56. Signals
  57. -------
  58. .. _class_MultiplayerSynchronizer_signal_delta_synchronized:
  59. .. rst-class:: classref-signal
  60. **delta_synchronized** **(** **)**
  61. Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.
  62. .. rst-class:: classref-item-separator
  63. ----
  64. .. _class_MultiplayerSynchronizer_signal_synchronized:
  65. .. rst-class:: classref-signal
  66. **synchronized** **(** **)**
  67. Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.
  68. .. rst-class:: classref-item-separator
  69. ----
  70. .. _class_MultiplayerSynchronizer_signal_visibility_changed:
  71. .. rst-class:: classref-signal
  72. **visibility_changed** **(** :ref:`int<class_int>` for_peer **)**
  73. Emitted when visibility of ``for_peer`` is updated. See :ref:`update_visibility<class_MultiplayerSynchronizer_method_update_visibility>`.
  74. .. rst-class:: classref-section-separator
  75. ----
  76. .. rst-class:: classref-descriptions-group
  77. Enumerations
  78. ------------
  79. .. _enum_MultiplayerSynchronizer_VisibilityUpdateMode:
  80. .. rst-class:: classref-enumeration
  81. enum **VisibilityUpdateMode**:
  82. .. _class_MultiplayerSynchronizer_constant_VISIBILITY_PROCESS_IDLE:
  83. .. rst-class:: classref-enumeration-constant
  84. :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` **VISIBILITY_PROCESS_IDLE** = ``0``
  85. Visibility filters are updated during process frames (see :ref:`Node.NOTIFICATION_INTERNAL_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PROCESS>`).
  86. .. _class_MultiplayerSynchronizer_constant_VISIBILITY_PROCESS_PHYSICS:
  87. .. rst-class:: classref-enumeration-constant
  88. :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` **VISIBILITY_PROCESS_PHYSICS** = ``1``
  89. Visibility filters are updated during physics frames (see :ref:`Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PHYSICS_PROCESS>`).
  90. .. _class_MultiplayerSynchronizer_constant_VISIBILITY_PROCESS_NONE:
  91. .. rst-class:: classref-enumeration-constant
  92. :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` **VISIBILITY_PROCESS_NONE** = ``2``
  93. Visibility filters are not updated automatically, and must be updated manually by calling :ref:`update_visibility<class_MultiplayerSynchronizer_method_update_visibility>`.
  94. .. rst-class:: classref-section-separator
  95. ----
  96. .. rst-class:: classref-descriptions-group
  97. Property Descriptions
  98. ---------------------
  99. .. _class_MultiplayerSynchronizer_property_delta_interval:
  100. .. rst-class:: classref-property
  101. :ref:`float<class_float>` **delta_interval** = ``0.0``
  102. .. rst-class:: classref-property-setget
  103. - void **set_delta_interval** **(** :ref:`float<class_float>` value **)**
  104. - :ref:`float<class_float>` **get_delta_interval** **(** **)**
  105. Time interval between delta synchronizations. When set to ``0.0`` (the default), delta synchronizations happen every network process frame.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_MultiplayerSynchronizer_property_public_visibility:
  109. .. rst-class:: classref-property
  110. :ref:`bool<class_bool>` **public_visibility** = ``true``
  111. .. rst-class:: classref-property-setget
  112. - void **set_visibility_public** **(** :ref:`bool<class_bool>` value **)**
  113. - :ref:`bool<class_bool>` **is_visibility_public** **(** **)**
  114. Whether synchronization should be visible to all peers by default. See :ref:`set_visibility_for<class_MultiplayerSynchronizer_method_set_visibility_for>` and :ref:`add_visibility_filter<class_MultiplayerSynchronizer_method_add_visibility_filter>` for ways of configuring fine-grained visibility options.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_MultiplayerSynchronizer_property_replication_config:
  118. .. rst-class:: classref-property
  119. :ref:`SceneReplicationConfig<class_SceneReplicationConfig>` **replication_config**
  120. .. rst-class:: classref-property-setget
  121. - void **set_replication_config** **(** :ref:`SceneReplicationConfig<class_SceneReplicationConfig>` value **)**
  122. - :ref:`SceneReplicationConfig<class_SceneReplicationConfig>` **get_replication_config** **(** **)**
  123. Resource containing which properties to synchronize.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_MultiplayerSynchronizer_property_replication_interval:
  127. .. rst-class:: classref-property
  128. :ref:`float<class_float>` **replication_interval** = ``0.0``
  129. .. rst-class:: classref-property-setget
  130. - void **set_replication_interval** **(** :ref:`float<class_float>` value **)**
  131. - :ref:`float<class_float>` **get_replication_interval** **(** **)**
  132. Time interval between synchronizations. When set to ``0.0`` (the default), synchronizations happen every network process frame.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_MultiplayerSynchronizer_property_root_path:
  136. .. rst-class:: classref-property
  137. :ref:`NodePath<class_NodePath>` **root_path** = ``NodePath("..")``
  138. .. rst-class:: classref-property-setget
  139. - void **set_root_path** **(** :ref:`NodePath<class_NodePath>` value **)**
  140. - :ref:`NodePath<class_NodePath>` **get_root_path** **(** **)**
  141. Node path that replicated properties are relative to.
  142. If :ref:`root_path<class_MultiplayerSynchronizer_property_root_path>` was spawned by a :ref:`MultiplayerSpawner<class_MultiplayerSpawner>`, the node will be also be spawned and despawned based on this synchronizer visibility options.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_MultiplayerSynchronizer_property_visibility_update_mode:
  146. .. rst-class:: classref-property
  147. :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` **visibility_update_mode** = ``0``
  148. .. rst-class:: classref-property-setget
  149. - void **set_visibility_update_mode** **(** :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` value **)**
  150. - :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` **get_visibility_update_mode** **(** **)**
  151. Specifies when visibility filters are updated (see :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` for options).
  152. .. rst-class:: classref-section-separator
  153. ----
  154. .. rst-class:: classref-descriptions-group
  155. Method Descriptions
  156. -------------------
  157. .. _class_MultiplayerSynchronizer_method_add_visibility_filter:
  158. .. rst-class:: classref-method
  159. void **add_visibility_filter** **(** :ref:`Callable<class_Callable>` filter **)**
  160. Adds a peer visibility filter for this synchronizer.
  161. \ ``filter`` should take a peer ID :ref:`int<class_int>` and return a :ref:`bool<class_bool>`.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_MultiplayerSynchronizer_method_get_visibility_for:
  165. .. rst-class:: classref-method
  166. :ref:`bool<class_bool>` **get_visibility_for** **(** :ref:`int<class_int>` peer **)** |const|
  167. Queries the current visibility for peer ``peer``.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_MultiplayerSynchronizer_method_remove_visibility_filter:
  171. .. rst-class:: classref-method
  172. void **remove_visibility_filter** **(** :ref:`Callable<class_Callable>` filter **)**
  173. Removes a peer visibility filter from this synchronizer.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_MultiplayerSynchronizer_method_set_visibility_for:
  177. .. rst-class:: classref-method
  178. void **set_visibility_for** **(** :ref:`int<class_int>` peer, :ref:`bool<class_bool>` visible **)**
  179. Sets the visibility of ``peer`` to ``visible``. If ``peer`` is ``0``, the value of :ref:`public_visibility<class_MultiplayerSynchronizer_property_public_visibility>` will be updated instead.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_MultiplayerSynchronizer_method_update_visibility:
  183. .. rst-class:: classref-method
  184. void **update_visibility** **(** :ref:`int<class_int>` for_peer=0 **)**
  185. Updates the visibility of ``for_peer`` according to visibility filters. If ``for_peer`` is ``0`` (the default), all peers' visibilties are updated.
  186. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  187. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  188. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  189. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  190. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  191. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  192. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`