Joining an ongoing multiplayer game and dealing with incoming RPCs

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gabrjt

Godot version:
3.0

OS/device including version:
Windows 10

Issue description:
Hello all.
I’m a new Godot user and I’m experimenting the multiplayer API.

I didn’t make a lobby like in most of the demos. So the server is always running, and clients connect to it.
When a client connects, a new entity is created for him and authority is granted.
This entity have some sync vars.
So far so good.

But when a second client connects, it immediately receives the state sync of the previous client entity even before the entities are created in this new client, resulting in errors…

Is there a way to ignore incoming packets if the client is in a “joining game” state?
Or buffer the packets and deliver to the target entity when it’s instantiated?

Steps to reproduce:
I’ve made a little separation of concerns so far, so there is a MasterNetwork scene and a SlaveNetwork scene… Some files were divided in BaseClass/MasterClass/SlaveClass also.

I don’t know if this is the best approach for Godot multiplayer development, but it’s working so far. I would appreciate some feedback on this. Let me know if I’m not being Godotish, in terms of using the engine the way it’s meant to be used.

Download the project, open the server and client projects with 3 different Godot editors. (I use symlinks to keep them synchronized).
Don’t forget to change the remote debugger port for each editor and set the main scenes (NetworkMaster for server, NetworkSlave for clients).
Play them all.

Thanks!

I’m dealing with the same issue myself. I know it’s been two years, but have you found a solution?

As for the answer below, I don’t see how stopping functions when it’s loading prevents incoming RPC’s.

Frolicks | 2020-09-04 22:24

:bust_in_silhouette: Reply From: mateusak

The ‘joining’ state depends on game to game. Create a singleton and a is_loading variable, which is true by default, when you finish loading all your stuff just set it to false. Then, yes, you have do to almost everywhere

if is_loading:
    return

There’s a reason why most games don’t allow players to enter mid game, it’s very complicated to sync them up with everything that has happened so far. Imagine there’s a destructible box. A player destroys it, and then another player logs in. How do you sync it up? The master has to send to the new player the state of the box. If the master leaves, then you have to assign a new master.
I have not yet tested if it is possible to send your running scene to the new player. If it is, then Godot is amazing.