Godot Version
4.3
Question
I’m working very closely to this blog post: Multiplayer in Godot 4.0: Scene Replication – Godot Engine
The error only shows for the clients (for each client that spawns) and seems to have no impact on the final authority of the node on server or client. The error is:
E 0:00:03:0677 on_replication_start: The MultiplayerSynchronizer at path "/root/Lobby/Spawns/1822449508/PlayerInput" is unable to process the pending spawn since it has no network ID. This might happen when changing the multiplayer authority during the "_ready" callback. Make sure to only change the authority of multiplayer synchronizers during "_enter_tree" or the "_spawn_custom" callback of their multiplayer spawner.
<C++ Error> Condition "pending_sync_net_ids.is_empty()" is true. Returning: ERR_INVALID_DATA
<C++ Source> modules/multiplayer/scene_replication_interface.cpp:243 @ on_replication_start()
Working backwards from the error, this is the important part of the PlayerInput node script (I tested commenting out the rest of the script too) - also g.log
is just a print()
wrapper that prepends multiplayer.get_unique_id()
:
func _enter_tree() -> void:
g.log(">>Setting multiplayer authority to %s" % [str(get_parent().player_id)])
g.log(">>Network ID is %s" % [str(multiplayer.get_unique_id())])
g.log(">>Multiplayer Authority Before is %s" % [str(get_multiplayer_authority())])
set_multiplayer_authority(get_parent().player_id)
g.log(">>Multiplayer Authority After is %s" % [str(get_multiplayer_authority())])
This is the output when the player is spawned:
{1} >>Setting multiplayer authority to 1822449508
{1} >>Network ID is 1
{1} >>Multiplayer Authority Before is 1
{1} >>Multiplayer Authority After is 1822449508
...
{1822449508} >>Setting multiplayer authority to 1822449508
{1822449508} >>Network ID is 1822449508
{1822449508} >>Multiplayer Authority Before is 1
{1822449508} >>Multiplayer Authority After is 1822449508
Here is the code that is doing the player spawning (spawns
is the node registered with the MultiplayerSpawner’s SpawnPath):
func add_player(peer_id):
var player = Player.instantiate()
player.player_id = peer_id
player.name = str(peer_id)
spawns.add_child(player, true)
Some other Notes:
- Removing the
set_multiplayer_authority()
line removes the error - so that is the source line - When the PlayerInput node is selected in the Remote Scene viewer, the Inspector shows the correct MultiplayerAuthority for server and clients.
- I haven’t done much testing but it seems like this error is doing nothing? (I would hate to move forward without first understanding this error)
Thanks for reading! Please let me know if there is any more info I can provide. I’m curious if anyone else has seen this and I’ll update if I find out more. If no one knows I can try to put together a micro example tomorrow or the next day.