class_multiplayersynchronizer.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. Description
  12. -----------
  13. By default, ``MultiplayerSynchronizer`` synchronizes configured properties to all peers.
  14. 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>`.
  15. \ :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.
  16. 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.
  17. Properties
  18. ----------
  19. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  20. | :ref:`bool<class_bool>` | :ref:`public_visibility<class_MultiplayerSynchronizer_property_public_visibility>` | ``true`` |
  21. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  22. | :ref:`SceneReplicationConfig<class_SceneReplicationConfig>` | :ref:`replication_config<class_MultiplayerSynchronizer_property_replication_config>` | |
  23. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  24. | :ref:`float<class_float>` | :ref:`replication_interval<class_MultiplayerSynchronizer_property_replication_interval>` | ``0.0`` |
  25. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  26. | :ref:`NodePath<class_NodePath>` | :ref:`root_path<class_MultiplayerSynchronizer_property_root_path>` | ``NodePath("..")`` |
  27. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  28. | :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` | :ref:`visibility_update_mode<class_MultiplayerSynchronizer_property_visibility_update_mode>` | ``0`` |
  29. +--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+--------------------+
  30. Methods
  31. -------
  32. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`add_visibility_filter<class_MultiplayerSynchronizer_method_add_visibility_filter>` **(** :ref:`Callable<class_Callable>` filter **)** |
  34. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`get_visibility_for<class_MultiplayerSynchronizer_method_get_visibility_for>` **(** :ref:`int<class_int>` peer **)** |const| |
  36. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`remove_visibility_filter<class_MultiplayerSynchronizer_method_remove_visibility_filter>` **(** :ref:`Callable<class_Callable>` filter **)** |
  38. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_visibility_for<class_MultiplayerSynchronizer_method_set_visibility_for>` **(** :ref:`int<class_int>` peer, :ref:`bool<class_bool>` visible **)** |
  40. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`update_visibility<class_MultiplayerSynchronizer_method_update_visibility>` **(** :ref:`int<class_int>` for_peer=0 **)** |
  42. +-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. Signals
  44. -------
  45. .. _class_MultiplayerSynchronizer_signal_visibility_changed:
  46. - **visibility_changed** **(** :ref:`int<class_int>` for_peer **)**
  47. Emitted when visibility of ``for_peer`` is updated. See :ref:`update_visibility<class_MultiplayerSynchronizer_method_update_visibility>`.
  48. Enumerations
  49. ------------
  50. .. _enum_MultiplayerSynchronizer_VisibilityUpdateMode:
  51. .. _class_MultiplayerSynchronizer_constant_VISIBILITY_PROCESS_IDLE:
  52. .. _class_MultiplayerSynchronizer_constant_VISIBILITY_PROCESS_PHYSICS:
  53. .. _class_MultiplayerSynchronizer_constant_VISIBILITY_PROCESS_NONE:
  54. enum **VisibilityUpdateMode**:
  55. - **VISIBILITY_PROCESS_IDLE** = **0** --- Visibility filters are updated every idle process frame.
  56. - **VISIBILITY_PROCESS_PHYSICS** = **1** --- Visibility filters are updated every physics process frame.
  57. - **VISIBILITY_PROCESS_NONE** = **2** --- Visibility filters are not updated automatically, and must be updated manually by calling :ref:`update_visibility<class_MultiplayerSynchronizer_method_update_visibility>`.
  58. Property Descriptions
  59. ---------------------
  60. .. _class_MultiplayerSynchronizer_property_public_visibility:
  61. - :ref:`bool<class_bool>` **public_visibility**
  62. +-----------+------------------------------+
  63. | *Default* | ``true`` |
  64. +-----------+------------------------------+
  65. | *Setter* | set_visibility_public(value) |
  66. +-----------+------------------------------+
  67. | *Getter* | is_visibility_public() |
  68. +-----------+------------------------------+
  69. 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.
  70. ----
  71. .. _class_MultiplayerSynchronizer_property_replication_config:
  72. - :ref:`SceneReplicationConfig<class_SceneReplicationConfig>` **replication_config**
  73. +----------+-------------------------------+
  74. | *Setter* | set_replication_config(value) |
  75. +----------+-------------------------------+
  76. | *Getter* | get_replication_config() |
  77. +----------+-------------------------------+
  78. Resource containing which properties to synchronize.
  79. ----
  80. .. _class_MultiplayerSynchronizer_property_replication_interval:
  81. - :ref:`float<class_float>` **replication_interval**
  82. +-----------+---------------------------------+
  83. | *Default* | ``0.0`` |
  84. +-----------+---------------------------------+
  85. | *Setter* | set_replication_interval(value) |
  86. +-----------+---------------------------------+
  87. | *Getter* | get_replication_interval() |
  88. +-----------+---------------------------------+
  89. Time interval between synchronizes. When set to ``0.0`` (the default), synchronizes happen every network process frame.
  90. ----
  91. .. _class_MultiplayerSynchronizer_property_root_path:
  92. - :ref:`NodePath<class_NodePath>` **root_path**
  93. +-----------+----------------------+
  94. | *Default* | ``NodePath("..")`` |
  95. +-----------+----------------------+
  96. | *Setter* | set_root_path(value) |
  97. +-----------+----------------------+
  98. | *Getter* | get_root_path() |
  99. +-----------+----------------------+
  100. Node path that replicated properties are relative to.
  101. 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.
  102. ----
  103. .. _class_MultiplayerSynchronizer_property_visibility_update_mode:
  104. - :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` **visibility_update_mode**
  105. +-----------+-----------------------------------+
  106. | *Default* | ``0`` |
  107. +-----------+-----------------------------------+
  108. | *Setter* | set_visibility_update_mode(value) |
  109. +-----------+-----------------------------------+
  110. | *Getter* | get_visibility_update_mode() |
  111. +-----------+-----------------------------------+
  112. Specifies when visibility filters are updated (see :ref:`VisibilityUpdateMode<enum_MultiplayerSynchronizer_VisibilityUpdateMode>` for options).
  113. Method Descriptions
  114. -------------------
  115. .. _class_MultiplayerSynchronizer_method_add_visibility_filter:
  116. - void **add_visibility_filter** **(** :ref:`Callable<class_Callable>` filter **)**
  117. Adds a peer visibility filter for this synchronizer.
  118. \ ``filter`` should take a peer id :ref:`int<class_int>` and return a :ref:`bool<class_bool>`.
  119. ----
  120. .. _class_MultiplayerSynchronizer_method_get_visibility_for:
  121. - :ref:`bool<class_bool>` **get_visibility_for** **(** :ref:`int<class_int>` peer **)** |const|
  122. Queries the current visibility for peer ``peer``.
  123. ----
  124. .. _class_MultiplayerSynchronizer_method_remove_visibility_filter:
  125. - void **remove_visibility_filter** **(** :ref:`Callable<class_Callable>` filter **)**
  126. Removes a peer visibility filter from this synchronizer.
  127. ----
  128. .. _class_MultiplayerSynchronizer_method_set_visibility_for:
  129. - void **set_visibility_for** **(** :ref:`int<class_int>` peer, :ref:`bool<class_bool>` visible **)**
  130. 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.
  131. ----
  132. .. _class_MultiplayerSynchronizer_method_update_visibility:
  133. - void **update_visibility** **(** :ref:`int<class_int>` for_peer=0 **)**
  134. Updates the visibility of ``peer`` according to visibility filters. If ``peer`` is ``0`` (the default), all peers' visibilties are updated.
  135. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  136. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  137. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  138. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  139. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  140. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`