MultiplayerSynchronizer failing to sync for late-joiners

Godot Version

4.5

I have some problems with MultiplayerSynchronizer not synchronizing properties, such as position.

I have my two clients (lets call them client A and client B) which connect to a server.

If client A connects to the server and spawns a character controller, and then client B connects to the server, client A’s character controller is spawned to client B’s instance, but it does not move if client A moves the character on his screen. By observing the server’s view, I can see that client A’s controller is synced to the server.

I also validated that the authority is same on the character controller for both client’s, by printing get_multiplayer_authority()

If client A and client B is both connected to the server when client A spawn’s their character, client B can see the client A move their character

Note: I dont use MultiplayerSpawner

Note2: I can see some rpc calls called by the Client A happening on Client B, such as jumping animations, shooting


I spawn characters for late joiners like this:

	var player_scene = load("res://entities/Player.tscn")
	var player: Player = player_scene.instantiate()
	player.set_entity_info(entity_info)

	get_tree().root.get_node("Game").add_child.call_deferred(player)

player.set_entity_info(entity_info) sets the Node’s name to be the authority id

and in the player scripts _enter_tree(), I have

	set_multiplayer_authority(int(name))

I feel like i might be using the MultiplayerSynchronizer wrong, but I didnt find much information on this issue :frowning:

Any help would be greatly appreciated

Do you recieve any error-messages?

What update options did you set in the synchronizer?

1 Like
E 0:00:21:235   get_node: Node not found: "Game/1589129591/MultiplayerSynchronizer" (relative to "/root").
  <C++ Error>   Method/function failed. Returning: nullptr
  <C++ Source>  scene/main/node.cpp:1908 @ get_node()
E 0:00:21:235   process_simplify_path: Parameter "node" is null.
  <C++ Source>  modules/multiplayer/scene_cache_interface.cpp:116 @ process_simplify_path()

I see this error.

From what i understand, the synchronizer is trying to sync before I have initialized the player character for Client B?

My visibility update mode is set to Idle.

You recon I have to set the public visibility to false, and then update visiblity for each connecting player?

Yes the problem seems to be that it cant find the synchronizer on the other peer. Im not sure though how to fix this. you can try to use the visibility options

1 Like

You definitely should, the reason being synchronizer will start sending packets without knowing if the receiver has spawned its remote instance. Spawners will wait for a confirmation packet before allowing their managed synchronizers to start talking.

If you don’t want spawners and you are using a syncers visibility mechanism, you could probably devise a way to confirm the remote peer has spawned their instance before changing visibility.

2 Likes

@herrspaten @pennyloafers thanks for the advice!

After fiddling around with MultiplayerSpawner a bit, I found the error I’ve made

I have a Menu.tscn scene, which contains the network connection+hosting logic.

So the order of operations would be:
Press connect in Menu.tscn => Client connects => Change the active scene to the host’s map => Spawn players and sync properties to the map

Menu.tscn does NOT have the MultiplayerSpawner or MultiplayerSychronizer nodes, so when the client tries to connect to the server, it can’t find the nodes, and it fails to sync.

I fixed this by creating a “staging” scene, which contains the MultiplayerSpawner and sychronizers, so the order of operations are as following:

Press connect in Menu.tscn => Client loads into the “staging” scene, which constains MultiplayerSpawner => Client connects => Add the map as a child node => Sync properties

1 Like