Unreal Engine Game Server Client Plugin

This is the Unreal Engine 4 Agones Game Server Client Plugin.

Check the Client SDK Documentation for more details on each of the SDK functions and how to run the SDK locally.

Download

Download the source from the Releases Page or directly from GitHub .

Resources

Unreal is a game engine that is used by anyone from hobbiests all the way through to huge AAA Game Stuidos.

With this in mind there is a vast amount to learn to run a production game using Unreal, even before you get to learning how it integrates with Agones. If you want to kick the tires with a starter project you will probably be fine with one of the starter projects out of the box.

However as your Unreal/Agones project gets more advanced you will want to understand more about the engine itself and how it can be used to integrate with this project. There will be different ways of interacting wether in Play In Editor (PIE) or running as an actual dedicated game server packaged into a container.

A few helpful links for Unreal:

Getting Started

This is a SDK inspired by the REST API to the Agones sidecars that allows engineers to communicate with the sidecar from either C++ or Blueprints.

Getting the Code

Easiest way to get this code is to clone the repository and drop the entire plugin folder into your own Plugins folder. This runs the plugin as a Project plugin rather than an engine plugin.

We could however turn this into a marketplace plugin that can be retrived from the marketplace directly into the UE4 editor.

Using C++

  • Add Plugin (in your own .uplugin file)
  "Plugins": [
    {
      "Enabled": true,
      "Name": "Agones"
    }
  ],
  • Add Plugin (in your own *.Build.cs)
PublicDependencyModuleNames.AddRange(
    new[]
    {
        "Agones",
    });
  • Add component in header
#include "AgonesComponent.h"

UPROPERTY(EditAnywhere, BlueprintReadWrite)
UAgonesComponent* AgonesSDK;
  • Initialize component in GameMode
#include "AgonesComponent.h"
#include "Classes.h"

ATestGameMode::ATestGameMode()
{
	AgonesSDK = CreateDefaultSubobject<UAgonesComponent>(TEXT("AgonesSDK"));
}
  • Use the Agones component to call PlayerReady
void APlatformGameSession::PostLogin(APlayerController* NewPlayer)
{
  // Empty brances are for callbacks on success and errror.
  AgonesSDK->PlayerConnect("netspeak-player", {}, {});
}

Using Blueprints

  • Add Component to your Blueprint GameMode component

  • This will automatically call /health every 10 seconds and once /gameserver calls are succesful it will call /ready.

  • Accessing other functionality of Agones can be done via adding a node in Blueprints. actions

Configuration Options

A number of options can be altered via config files in Unreal these are supplied via Game configuration eg. DefaultGame.ini.

[/Script/Agones.AgonesComponent]
HttpPort=1337
HealthRateSeconds=5.0
bDisableAutoConnect=true

SDK Functionality

Additional methods have been added for ease of use (both of which are enabled by default):

  • Connect
    • will call /gameserver till a succesful response is returned and then call /ready.
    • disabled by setting bDisableAutoConnect to true.
    • An event is broadcast with the GameServer data once the /gameserver call succeeds.
  • Health
    • calls /health endpoint on supplied rate
    • enabled by default with 10 second rate
    • disabled by default by setting HealthRateSeconds to 0.

Both of the above are automatically kicked off in the BeginPlay of the component.

This Agones SDK wraps the REST API and supports the following actions:

Stable

  • Lifecycle
    • Ready
    • Health
    • Reserve
    • Allocate
    • Shutdown
  • Configuration
    • GameServer
  • Metadata
    • SetAnnotation
    • SetLabel

Alpha

  • Player Tracking
    • GetConnectedPlayers
    • GetPlayerCapacity
    • GetPlayerCount
    • IsPlayerConnected
    • PlayerConnect
    • PlayerDisconnect
    • SetPlayerCapacity

Unimplemented

  • WatchGameServer

Current the only missing functionality is the WatchGameServer functionality. We welcome collaborators to help implement this, if people need it before we get around to implementing it ourselves.

Unreal Hooks

Within the Unreal GameMode and GameSession exist a number of useful existing funtions that can be used to fit in with making calls out to Agones.

A few examples are:

  • RegisterServer to call SetLabel, SetPlayerCapacity
  • PostLogin to call PlayerConnect
  • NotifyLogout to call PlayerDisconnect

Last modified October 16, 2020: Useful Unreal links (#1846) (6c60741a)