Godot Version
Using Godot 4.4
Question
I have the following code in my Lootbag scene:
func broadcast_lootbag_update():
for player_id in nearby_players:
send_lootbag_contents.rpc_id(player_id, item_data)
if len(items) == 0:
queue_free()
Every time the lootbag content changes, this function is called, updating all the players of the new contents. The send_lootbag_contents function has this signature:
@rpc("authority", "call_local", "reliable", 69)
func send_lootbag_contents(item_data: Array[Dictionary]):
assert(!multiplayer.is_server())
# ... code
But there’s a race condition here; because the Lootbag scene is replicated with MultiplayerSynchronizer, if the queue_free() is executed before the send_lootbag_contents, then (presumably) the client will error out or something, since it can’t find the object the RPC is sent on.
Perhaps I’m overthinking an issue that doesn’t exist, but to be sure it’s safe I wanted to set the transfer channel of the MultiplayerSynchronizer to the same as the rpc call to hope there’s no order problems. How can I do this, or am I doing something dumb?