I’m setting up multiplayer support and while I do have server -> client communication working, I’m having difficulties determining the best way for the server to know which clients are connected, once connected through the Join Session node.
I had a few questions as well:
Is there an event called when a client joins using Join Session?
Can you store clients in variables to allow server talk to specific clients, or do you have to multicast to all of them?
GameInstances don’t seem to be replicated, so how do I pass server stored variables across levels?
-You could override OnPostLogin() in the GameMode. It also gives you a reference to the joined PlayerController.
-You could use the PlayerControllers to differentiate the players, in fact, you could use the references obtained in OnPostLogin()(by storing them in an array).
-No, I think it is not replicated, but you could use the server’s Game Instance to store important values and read them later from another class in a server event.
I am nowhere to be a networking expert, so I hope it will make sense. Please note, that I’m not 100% sure about my last answer, please try to check out other sources as well about that.
OnPostLogin seems like it might be the right step. What’s being problematic is I’m not sure how to go from the player controller reference to assigning that client an ID that is saved on the client.
The GameMode exists only on server. You can add a variable for the client’ sID there. Increment it on each OnPostLogin call and add it to the client’s pawn or wherever you want the ID.