Gamemode multiplayer [C++]

Hi!

I have some questions regarding the gamemode in unreal engine that I haven’t been able to find any answers to.

One, is it always possible to join a “gamemode” with e.g. "open " command? How to turn off/on the listen server, e.g. in a single player game it would probably be considered a hack to rejecting incoming connections instead of stop listening for connections, the same goes from menus? How is this controlled?

Two, I understand that you can use the online subsystem to allow searching for servers and so on but how do you implement a simple join IP system in pure C++ code without any console commands?

I think a better understanding for this really would help me understand the engine a lot better =) I have looked at the shooter game example and from what I have understood it relies on the NULL implementation of the online subsystem. Maybe it’s obvious but I haven’t found answers for those questions yet and find it kinda fundamental to understand how the gamemode works in order to build a game and is a bit surprised so few details are mentioned about it in the documentation.

Thanks in advance!

Hi Undercover,

To answer your first question, you actually have to opt-in to be a listen server, so by default you actually aren’t listening for connections. To opt-in (and listen for connections), when you load a level, add the ?Listen option to the level name (open MyGame MyLevel?Listen -game).

To join a server directly (bypassing online subsystem) using c++, you can call ClientTravel on the player controller for that machine: PlayerController->ClientTravel( TEXT( “ip:port” ), TRAVEL_Absolute );

Hope that helps!

Thanks a lot! This really helps me to understand how the networking should be used. What method is used to host/start the server? Is is InitGame?

The high level call would be GetWorld()->ServerTravel( TEXT( “MapName?Listen” ) );

This will open the map call “MapName”, and start listening for connections.