C++ Networking in UE4

For the Skyforce prototype we did all of our networking in UE4s blueprint system which was great for getting a network set up quickly, but it didn’t give us total control of things like the server name and server travelling. For the Sky Noon development we have started our network from scratch using c++. Epic games have a free “Shooter Game” example in their market place which is a networked first person shooter based in c++, this provided an excellent reference to learn how to set up sessions and use sub systems in c++. We have interfaced our networking with an in game Slate UI. At this stage we only have placeholder assets but they work as intended.

Main Menu Screenshot

When the player clicks the Host Game button we get a pointer to our custom game instance and enter the URL details we want into a string. At the moment the game will always host as a free for all and launch to our game lobby but in future we would want to let the player determine the mode from the lobby while the session is active. We then pass on this string into our host game function, along with the main player controller.

Host Game Clicked

The game instance adds an OnCreatePresenceSessionComplete delegate and determines whether or not the session is a LAN match or not. We then pass on information from our travel URL to our game session class for the actual session creation to take place.

Game instance host
The game session class is where we use UE4’s Online Sub System to create the session. This allows us to easily make our game integrated with Steam and hopefully PS4 in future development. This is done simply by filling out our session parameter structure and and calling the IOnlineSessionPtr CreateSession() function.

Session Host Game

Now this session can be found in our server list widget and the session name is the host’s Steam alias. At the moment we have a problem where in the server list the ping always shows as 9999 when we are using steam as our subsystem but when we are in the game it shows the real ping. The player count has also been somewhat temperamental when using the steam subsystem and we will be working hard to fix these problems next week.


When we double click the session we call code from the game instance and eventually our game session calls JoinSession() which gets an IOnlineSessionPtr and joins the session based on the host’s user ID, session name and the search result from the server list widget.

Join Session

Voila! We have now joined the host’s game session and using our scoreboard we can see all of the users that are connected as well as our current ping.


What’s to come in Sky Noon networking:

  • Fix 9999 ping and server player count
  • Lobby show current players
  • Choose Game mode and other Game Settings from the lobby
  • Message dialogues for network warnings
  • Host able to kick players

-Lunar Rooster

Leave a Reply