Questions about RPC in place of MultiplayerSynchronizer

Godot Version

4.3+

Question

Evening fellow godooters!
This is assuming it’s a casual game (unnoticeable latency is fine etc) and you couldn’t use a MultiSynchro for w/e reason (ie. different node paths) and needs to be constantly updated like position etc.

What I’m thinking is to use an RPC to transfer data manually ie. send_node_data.rpc(node_name, variable) then grab that node from a dictionary and set it (theoretic example below).

  1. At what point would that be a noticeable performance or latency loss in comparison to MultiplayerSynchronizers?
  2. What pitfalls are there to look out for?
  3. Do MultiSynchro’s use channels? To emulate one is using a single channel with reliable fine if you were updating multiple nodes (idk like 30ish) or is there a better way?

After some self research I understand:

Random Theoretic Example:

On the multiplayer manager or w/e:

var dict_of_nodes := { "node_name_a":"name", "node_name_b":"name" }

signal network_frame_tick

# Send out a network frame tick
func _physics_process( _delta:float ) -> void:
	if Engine.get_physics_frames() % 2 == 0:
		network_frame_tick.emit()


# Get and update the node on a channel specifically for this
@rpc ("any_peer", "call_remote", "reliable", 1)
func update_node_data( node_name:String, pos:Vector2 ) -> void:
	var found_node = dict_of_nodes.get( node_name )
	if found_node:
		found_node.position = pos

On the node that needs to send updates:

func _on_network_frame_tick() -> void:
	if is_multiplayer_authority():
		update_node_data.rpc( name, position )
  1. Performance difference depends on what you send.
    If you send every frame (equal to synchronizer set to always) you should use “unreliable” as rpc-option. If you know your data, you can try to reduce it to send less data everytime. Optimizing to your needs should always be “faster” then the built-in version.
  2. Pitfalls could always be, that someone (a hacker) might send false data (e.g. string instead of a int), so you should check that the recieved data is correct to avoid game-crashing
  3. i dont know about the channels
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.