Integrating GSDK with Unreal

You can find the Unreal GSDK here. This folder contains the Game Server SDK for the Unreal game engine.

What do I need to do in order to use the Unreal GSDK in a new project?

The Unreal server project needs to be a network-enabled multiplayer Unreal project with a dedicated-server mode. If you don’t have a project that meets these prerequisites, follow our Unreal prerequisite set up guide to set one up. Once you have a network-enabled, multiplayer game, with a dedicated server, return to this step and continue.

When ready, open your network-enabled multiplayer Unreal server project, and continue to the next step, specifically to the part about building for the cloud.

At a minimum, you would need to call the SetDefaultServerHostPort() to get the port your server should listen to and ReadyForPlayers() method to transition your server to the StandingBy state.

#if UE_SERVER
    UGSDKUtils::SetDefaultServerHostPort();
#endif

// ...

void U[YourGameInstanceClassName]::OnStart()
{
    UE_LOG(LogPlayFabGSDKGameInstance, Warning, TEXT("Reached onStart!"));
    UGSDKUtils::ReadyForPlayers();
}

To create your container image to use on Kubernetes, you should build a “Linux Dedicated Server” and then use a Dockerfile similar to the following:

FROM ubuntu:18.04

# Unreal refuses to run as root user, so we must create a user to run as
# Docker uses root by default
RUN useradd --system ue
USER ue

EXPOSE 7777/udp

WORKDIR /server

COPY --chown=ue:ue . /server
USER root
CMD su ue -c ./ShooterServer.sh

Samples

Check this guide on how to integrate the Unreal Third Person template with the Unreal GSDK.

Testing with LocalMultiplayerAgent

You can use LocalMultiplayerAgent to test your GSDK integration of your game server before uploading to Thundernetes.

Other GSDK methods and callbacks

There are some other GSDK methods you can use from your game server process:

  • GetGameServerConnectionInfo: Returns the connection information for the GameServer. Usually, it should be the port that you have already defined in your Pod specification. It is required use this method if you want to use the hostNetwork option.
  • GetInitialPlayers: Returns the IDs of the players that are expected to connect to the GameServer when it starts. It is set during the call to the allocation service API.
  • UpdateConnectedPlayers: It updates the currently connected players to the GameServer. On the backend, Thundernetes updates the GameServerDetail Custom Resource with the new number and IDs of connected players.
  • GetConfigSettings: Returns the current configuration settings for the GameServer. You can retrieve the associated GameServerBuild metadata with this method.
  • GetLogsDirectory: Returns the path to the directory for the GameServer logs. It is recommended to just send the logs to standard output/standard error streams, where you can use a Kubernetes-native logging solution to grab them.
  • LogMessage: Writes an entry to the log file. As mentioned, it is recommended to send your logs to standard output/standard error streams
  • GetSharedContentDirectory: Not used in Thundernetes
  • RegisterMaintenanceCallback (name might be slightly different depending on your environment): Used to determine the Health status of the GameServer
  • RegisterMaintenanceCallback (name might be slightly different depending on your environment): Not used in Thundernetes
  • RegisterShutdownCallback (name might be slightly different depending on your environment): Not used in Thundernetes