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).
- At what point would that be a noticeable performance or latency loss in comparison to MultiplayerSynchronizers?
- What pitfalls are there to look out for?
- 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:
- You can reduce the size of packets
- MultiSynchros send on network ticks (I would be sending approx every second physics frame)
- That only the node’s authority sends updates to other clients
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 )