Class MultiplayerSynchronizer
- Namespace
- Godot
- Assembly
- GodotSharp.dll
By default, MultiplayerSynchronizer synchronizes configured properties to all peers.
Visibility can be handled directly with SetVisibilityFor(int, bool) or as-needed with AddVisibilityFilter(Callable) and UpdateVisibility(int).
MultiplayerSpawners will handle nodes according to visibility of synchronizers as long as the node at RootPath was spawned by one.
Internally, MultiplayerSynchronizer uses ObjectConfigurationAdd(GodotObject, Variant) to notify synchronization start passing the Node at RootPath as the object
and itself as the configuration
, and uses ObjectConfigurationRemove(GodotObject, Variant) to notify synchronization end in a similar way.
Note: Synchronization is not supported for GodotObject type properties, like Resource. Properties that are unique to each peer, like the instance IDs of GodotObjects (see GetInstanceId()) or Rids, will also not work in synchronization.
public class MultiplayerSynchronizer : Node, IDisposable
- Inheritance
-
MultiplayerSynchronizer
- Implements
- Inherited Members
Constructors
MultiplayerSynchronizer()
public MultiplayerSynchronizer()
Properties
DeltaInterval
Time interval between delta synchronizations. When set to 0.0
(the default), delta synchronizations happen every network process frame.
public double DeltaInterval { get; set; }
Property Value
PublicVisibility
Whether synchronization should be visible to all peers by default. See SetVisibilityFor(int, bool) and AddVisibilityFilter(Callable) for ways of configuring fine-grained visibility options.
public bool PublicVisibility { get; set; }
Property Value
ReplicationConfig
Resource containing which properties to synchronize.
public SceneReplicationConfig ReplicationConfig { get; set; }
Property Value
ReplicationInterval
Time interval between synchronizations. When set to 0.0
(the default), synchronizations happen every network process frame.
public double ReplicationInterval { get; set; }
Property Value
RootPath
Node path that replicated properties are relative to.
If RootPath was spawned by a MultiplayerSpawner, the node will be also be spawned and despawned based on this synchronizer visibility options.
public NodePath RootPath { get; set; }
Property Value
VisibilityUpdateMode
Specifies when visibility filters are updated (see MultiplayerSynchronizer.VisibilityUpdateModeEnum for options).
public MultiplayerSynchronizer.VisibilityUpdateModeEnum VisibilityUpdateMode { get; set; }
Property Value
Methods
AddVisibilityFilter(Callable)
Adds a peer visibility filter for this synchronizer.
public void AddVisibilityFilter(Callable filter)
Parameters
filter
Callable
GetVisibilityFor(int)
Queries the current visibility for peer peer
.
public bool GetVisibilityFor(int peer)
Parameters
peer
int
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
RemoveVisibilityFilter(Callable)
Removes a peer visibility filter from this synchronizer.
public void RemoveVisibilityFilter(Callable filter)
Parameters
filter
Callable
SetVisibilityFor(int, bool)
Sets the visibility of peer
to visible
. If peer
is 0
, the value of PublicVisibility will be updated instead.
public void SetVisibilityFor(int peer, bool visible)
Parameters
UpdateVisibility(int)
Updates the visibility of forPeer
according to visibility filters. If forPeer
is 0
(the default), all peers' visibilties are updated.
public void UpdateVisibility(int forPeer = 0)
Parameters
forPeer
int
Events
DeltaSynchronized
Emitted when a new delta synchronization state is received by this synchronizer after the properties have been updated.
public event Action DeltaSynchronized
Event Type
Synchronized
Emitted when a new synchronization state is received by this synchronizer after the properties have been updated.
public event Action Synchronized
Event Type
VisibilityChanged
Emitted when visibility of forPeer
is updated. See UpdateVisibility(int).
public event MultiplayerSynchronizer.VisibilityChangedEventHandler VisibilityChanged