Godot Version
4.4.1
Question
I’m working on a client/server architecture for my game. My main scene has top level nodes for Lobbies and Games, and a spawner for both. In the Lobby scene, I have a MultiplayerSynchronizer with Public Visibility = false. In a server manager script, I have logic like this…
func create_lobby(lobby_id : String) -> void:
if not multiplayer.is_server():
return
var client_id = multiplayer.get_remote_sender_id()
var lobby = load("res://interface/lobby/Lobby.tscn").instantiate()
lobby.name = lobby_id
lobby.lobby_id = lobby_id
lobby.lobby_host = client_id
lobby.set_multiplayer_authority(1)
lobby.syncro.set_visibility_for(client_id, true)
$/root/Main/Lobbies.add_child(lobby)
The lobby scene itself also has a MultiplayerSpawner called PlayerNameSpawner.
Now, if I run a server and two clients, when I create a lobby on one client, I see an interesting behavior.
Using the debugger, if I inspect the runtime scene tree on all three, I see the expected scene structure. The server and the client who created the lobby see the lobby added into the correct place within the scene tree, and the client who didn’t create the lobby doesn’t see that scene in the scene tree at all. Great!
However, I also get an error on the client who didn’t create the lobby.
E 0:00:15:101 get_node: Node not found: "Main/Lobbies/6c4f6ffb-3180-49ef-9816-4cab1d9369de/PlayerNameSpawner" (relative to "/root").
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1877 @ get_node()
It’s almost as if the PlayerNameSpawner is expecting all clients to have that node in the scene tree, even though that isn’t the case?