When running from editor, how can I prevent the client from automatically connecting to the dedicated server immediately upon startup? I’d like to create a lobby screen first, and the player should click a button before triggering the client travel to the server.
I’ve tried extending AGameSession and using AGameSession::ApproveLogin to prevent connection, but the client simply hangs and renders a black screen if it’s unable to connect. Could anyone point me to a resource, or somewhere in the UE source, that could show me what’s causing this behaviour on the client, so I can override it?
After doing some research, it turns out there used to be an option in the Networking Settings in the editor, for the Client to not automatically connect. It was removed sometime around Unreal v4.25 or v4.26.
The closest behaviour to this in UE5 is probably setting Net Mode to “Play as Standalone” and ticking the “Launch Separate Server” option in “Advanced (Network) Settings…”.
I’m guessing it’d also be doable by launching the server instance from the commandline instead of checking that “Launch Separate Server” option, although I haven’t tried/confirmed that approach.
For anyone looking for a solution to this like me using UE5, you can now use Play Standalone net mode in NetMode settings to stop your process from acting as a client or server.
Just a quick note this setting has nothing to do with Standalone Game mode option you see in the same image. Even if you start your game in Standalone Game mode, if your NetMode is set as Client or Listen Server the game will still try to act as either client or server on startup.