I am having trouble with multiplayer authority. I’ll attach my code but long story short when i call
set_multiplayer_authority(str(name).to_int())
when clicking join, to join the host player the authority is not set properly. If i print name and get_multiplayer_authority() the values are identical but if I print is_multiplayer_authority() I get false.
I’ve checked my code 100 times compared to the tutorials repo and as far as the world scene which handles the hosting and joining along with the setting authority in the enter_tree() function they are identical. I’ve added some other changes but can’t see how they’d effect the networking side.
I’ve created a repo so you can see my two scripts which handle the networking/player joining.
I’ve googled for almost 2 days trying to find the answer and can’t find many results. As I say I’ve added some things to the player like the subview port container which contains a weapon manager and stuff for the player first person view but can’t see how that would effect the multiplayer authority. I can upload this code if you think it’s pertinent.
I think I set my authority after ready function. By using call_deferred set multiplayer authority.
Anyways after you set authority, are you sure you are looking at the right instance of the game? I.e. looking at the host version of the client node?
That is_multiplayer_authority will by false on the server instance. You can call multiplayer.get_unique_id() to check who you are when that code is running.
Ok thanks, i’ve tried that and I get the same result.
While the game is running I go into the editor and look at the remote tree. I can see both players there and in the inspector they have their separate Multiplayer Authority ID’s correct yet the ready function doesn’t run past the if statement.
This could be tricky, but there are two instances of the game running and 4 player nodes total. Two on server side, two on client side
If we look at the client player node.name “123456”:
Server is authority returns false. Client side returns true.
If we look at server side player node.name “1”:
Server is authority returns true, client side returns false.
When running multiple instances there are different output tabs for each game instance.
I want to be clear that we are looking at the right instance. There is no indication on which window is running server and client. It can make it easier to isolate output if you run the server from command line. And run the client in the editor. You can then debug more easily what is going on.
Ok great idea. So i duplicated the project and ran it separately in two separate editors.
It seems that when I click join on the second client the add_player() function which instantiates the player doesn’t run on the client side. The host registers the player joining and creates the player object but nothing happens on the client side…
I get these in the debugger but googling doesn’t show up much
E 0:00:02:0376 get_node: Node not found: “World/1/MultiplayerSynchronizer” (relative to “/root”).
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1638 @ get_node()
E 0:00:02:0376 process_simplify_path: Parameter “node” is null.
<C++ Source> modules/multiplayer/scene_cache_interface.cpp:76 @ process_simplify_path()