As u can see by the title, I’m getting an error when instanciating a scene with a MultiplayerSynchronizer.
Older clients can see newer clients move but newer clients cannot see the updates.
I properly setup Both MultiplayerSynchronizer and MultiplayerSpawner:
Clients shouldn’t be creating their own players, the MultiplayerSpawner needs to handle replicating all spawned players.
The MultiplayerSpawner does not replicate any properties but the node’s name, which I also believe must be added as a child with force_readable_name enabled, which is the second argument of add_child. So position and set_multiplayer_authority are not changed for everybody, though later you do use set_multiplayer_authority in the player.gd’s _enter_tree which will happen for every client as long as they have the same player with the same name.to_int().
$Players.add_child(player, true)
# or deferred, but I don't think you want deferred
$Players.add_child.call_deferred(player, true)
Sure. A fairly basic set up would be to spawn the host’s player when the server starts, notice only the server ever calls _add_player, clients should not create players.
func _ready() -> void:
if multiplayer.is_server():
multiplayer.peer_connected.connect(_add_player)
multiplayer.peer_disconnected.connect(_remove_player)
_add_player(1)
I see, I don’t think Godot’s high level multiplayer can handle multiple “sessions” easily if that’s what you hope to do with room codes, you may need excessive network “visibility” management for your Synchronizers.
The Server may not need a player, but it still needs to be solely in charge of spawning players. Your server and client’s scene tree must match for the high level multiplayer nodes to function properly, spawning new nodes must take place on the server with a readable name through the assigned MultiplayerSpawner node.
It certainly makes a program much more complicated to hold multiple game states, I believe most room-code online games do ask players to host on their machine and use a sort of STUN/TURN server to connect the two (through the room code).