Integrate your game with Amazon GameLift - Amazon GameLift

Integrate your game with Amazon GameLift

This documentation is for a feature that is in public preview release. It is subject to change.

Before you can create a container image with your game server software and deploy it to Amazon GameLift for cloud hosting, first integrate your game project with the Amazon GameLift server SDK and build a game server to run on Linux. This topic introduces the various integration tools that Amazon GameLift provides.

Hosted game servers must be able to communicate with the Amazon GameLift service. Set up communication by adding the Amazon GameLift server SDK (version 5+) to your game project and modifying your game's server code. Amazon GameLift provides server SDK resources and documentation to support several languages and game engines.

The integration process for containerized game servers is virtually identical to integrating game servers for hosting on managed EC2 or Amazon GameLift Anywhere fleets.

Integration tools

Amazon GameLift provides the following tools and language support for integration:

For Unreal Engine developers

Use the lightweight plugin for Unreal. This plugin includes the C++ server SDK libraries with required Amazon GameLift functionality. Use the documentation to configure your Unreal game project for the plugin and update your game code with the provided code blocks to add required functionality for your server and client builds.

Note: The Amazon GameLift standalone plugin for Unreal Engine doesn't support the use of container fleets.

For Unity developers

Use the lightweight plugin for Unity. This plugin includes the C# server SDK libraries with required Amazon GameLift functionality. Use the documentation to configure your Unreal game project for the plugin and update your game code with the provided code blocks to add required functionality for your server and client builds.

Note: The Amazon GameLift standalone plugin for Unity doesn't support the use of container fleets.

For developers using other game engines

Follow this general server and client integration guidance:

Amazon GameLift offers server SDK 5 libraries for the following languages:

Build your game server for Linux

Amazon GameLift container fleets support game servers that run on a Linux platform. Here are some tips for building your game server for a Linux target:

  • If you're developing your game with the Unity game engine, the game editor provides built-in support with no special requirements to build for Linux.

  • If you're developing your game in C++, you must include the OpenSSL libraries for Linux when you build the Amazon GameLift server SDK for C++, and when you build your game server. Also include the same libraries in your game server container image.

  • If you're developing your game with Unreal Engine on Windows, consider these options:

    • Work with Unreal Engine to set up a cross-compile tool chain.

    • Set up a separate Linux workspace, or use a tool such as Windows subsystem for Linux (WSL). You can use this environment to run the Unreal Editor on Linux to build your game server.

Test your integration locally

You can test your game integration locally using an Amazon GameLift Anywhere fleet. This approach is a best practice to help isolate issues directly related to integration. An Anywhere fleet is a useful tool for running test apps and game scenarios, such as starting/stopping game sessions and tracking player connections. You can build and test iteratively much faster with an Anywhere fleet, which offers greater visibility into hosting activity.

See Set up local testing with Amazon GameLift Anywhere for help with using an Amazon GameLift Anywhere fleet for integration testing. The workflow for setting up a test environment looks like this:

  1. Set up a local device that's running Linux.

  2. Set up an Anywhere fleet. Create a custom location for your local device, create an Anywhere fleet, and then register your local device as a compute in the fleet.

  3. Get an authentication token for your game server. Your integrated server process requires a token to authenticate with the Amazon GameLift service. You can re-use the same token for multiple server processes running concurrently This step is required only when using an Anywhere fleet for integration testing.

    Note

    Authentication tokens are temporary and must be regularly refreshed. Consider adding a script to your server build package to request a new token.

  4. Update your game server code for Anywhere . When running on an Anywhere fleet, the game server needs to call the server SDK action InitSdk() (C++) (C#) (Unreal) with the following server parameters. This step is required only when using an Anywhere fleet for integration testing. After you add the Amazon GameLift Agent to your container image, it handles these parameters automatically.

    As a best practice, set up your server code to pull these values from environment variables or from console arguments that you specify on launch.

    • webSocketUrl – Use the value of GameLiftServiceSdkEndpoint, which is returned from the call to register-compute.

    • processId – Assign a unique identifier for the server process.

    • fleetId – The Anywhere fleet identifier, which is returned from the call to create-fleet.

    • authToken – A valid authentication token, which is returned from the call to get-compute-auth-token.

  5. On your local machine, set up your game server build software and launch a server process.

    If your server integration is successful, the server process calls the server SDK action InitSDK() to establish connection with the Amazon GameLift service, followed by a call to ProcessReady() to notify the service that its ready to host a game session.

  6. Start a game session. If you've integrated your game client to request a game session, you can use it to request a new game session. If not, use the AWS CLI command create-game-session. Amazon GameLift creates a GameSession object and initiates the process to start a new game session.

    If your integration is working, Amazon GameLift calls a server process on your local workstation to start a new game session (using the onStartGameSession() callback). When a game session is ready for players, the server process calls ActivateGameSession(). In response, Amazon GameLift updates the GameSession status and connection information so that a game client can connect to the game session and play the game.