In my recent multiplayer journey, I’ve learned how to create a dedicated server, connect clients to that server, and use RPCs in a dedicated server context.
However, when the a second player spawns in, they take control of the first player. This is an issue with client having authority over their own inputs. But I need to have more knowledge in order to fully implement it.
Questions
When I use the property is_multiplayer_authority(), I get confused. Does the dedicated server still have the final say over the client’s actions or does the player have the final say?
The dedicated server must of authority at all times in order to implement networking features needed for a PvP shooter.
Another option for client control would be checking if they have a matching id before every input. Speaking of.
I tried to see each client’s id and name using the print statement. However, when I start the game and join the dedicated server, the prints trigger numerous times and they sometimes don’t match.
It spawns both players on both peers, but prints to the same console. Notice the Peer Auth ID is the same twice with 75028… loading in player 75028… and player 14864… Then the peer 14864… loads in both players. If you had three players then each peer would need to load three player objects
Client 2 joins and takes control of their player. But they ALSO completely remove the input control of client 1.
If a third client joins, it removes the input control of client 2 and so on.
This issue happens regardless of synchronization method or lack thereof. I think the issue comes from how I set the client input authority and how I pass the id.
I’d be very surprised if your set_multiplayer_authority is called again with different values since it’s in _enter_tree, it will only be set once per player as it should.
Make sure your player’s camera’s current option is set to false by default.
Misc Tips:
When clients first spawn, they must also spawn all concurrent clients. This sounds obvious, but it flew over my head.
For a dedicated server setup, setting the client’s authority only grants access to their own inputs. The server still has the final say in whether the input goes through or not.
Edit: Here’s the solution for the duplicate console printing issue.