Tutorial on integrating Unreal with Amazon GameLift

This post and the tutorial series have both been updated to address more GameLift and UE4 multiplayer development concepts. You can watch the new tutorial here. More information about the new videos can be found in my answer to this question below.

ORIGINAL POST DOWN BELOW

Many times on here, I see questions about the confusing process of deploying a dedicated server to Amazon GameLift. These questions are warranted because of Amazon’s lackluster documentation. To ease the process, I decided to make a very simple tutorial on how to host a server on aws gamelift. Click here to watch.

These are some of the tiny things that gave me trouble that I go over to make sure that you don’t spend endless hours debugging a stupid issue:

##- Building Unreal source

Make sure you have the right .NET Framework SDKs and targeting packs installed (I happened to have both 4.5 and 4.6.1 installed). It seems for Visual Studio 2019, in addition to 4.5 and 4.6.1, you need to install .NET Framework SDK version 4.6.2. Note that you don’t need every SDK installed, just the targeting packs and the SDK for the highest version since targeting only works backwards. Visual Studio 2019 came with SDK version 4.7.1 so I’m not sure if you need this too but download it just in case.

Make sure you have MSBuild (under individual components of the Visual Studio Installer) installed whether it’s through the IDE or separately through the build tools.

Make sure you have the VC++ toolset (under individual components of the Visual Studio Installer) installed whether it’s 2015 or 2017 or 2019.

Before running the Setup and GenerateProjectFiles batch files, make sure the file path of the directory in which you are running the files in isn’t too long. Also, if using Visual Studio 2017, you need to add the -2017 tag when running GenerateProjectFiles. If using Visual Studio 2019, you need to add the -2019 tag when running GenerateProjectFiles.

Before compiling Unreal Engine, go to the VCToolChain.cs file located at the file path, Engine\Source\Programs\UnrealBuildTool\Platform\Windows. And after line 484, add these two lines,

Arguments.Add("/wd4800");
Arguments.Add("/wd5038");

This is to suppress certain warnings and will be fixed in 4.22.1.

##- Generating GameLiftServerSDK lib and dll files

When installing cmake and msbuild tools, make sure the file paths in your path variable are correct. For msbuild, the path with depend on your version of visual studio:

2015 -> C:\Program Files (x86)\MSBuild\14.0\Bin
2017 -> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
OR
2017 -> C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
2019 -> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin

Also, make sure your VCTargetsPath path variable is right depending on which version of build tools are being used:

2015 -> C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140
2017 -> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets
2019 -> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160

Note that this process currenlty doesn’t work with Visual Studio 2019 build tools, so you will have to use 2017 or 2015 build tools in the meantime.

With that noted, it may be good to define another system environment variable called VS140COMNTOOLS, VS150COMNTOOLS, or VS160COMNTOOLS. 140 corresponds with 2015, 150 corresponds with 2017, and 160 corresponds with 2019. And the value for this variable should be

2015 -> C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
2017 -> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools
2019 -> C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools

Don’t forget to have Git installed!

You will need to download the Visual C++ tools for Cmake as well.

And again, make sure the file path of the directory in which you’re running cmake and msbuild commands is not too long.

The cmake command for building the dll and lib files will depend on your version of visual studio:

cmake -G "Visual Studio 16 2019 Win64" -DBUILD_FOR_UNREAL=1 ..
cmake -G "Visual Studio 15 2017 Win64" -DBUILD_FOR_UNREAL=1 ..
cmake -G "Visual Studio 14 2015 Win64" -DBUILD_FOR_UNREAL=1 ..

The -G in the commands above are optional, but it can prevent errors when you’re using cmake with different versions of visual studio.

- Adding the gameliftserversdk and gameliftclientsdk plugins to your unreal project

Make sure to add bEnableExceptions = true to the build files for your project and the gameliftclientsdk.

##- Creating an iAM user with a security policy in AWS

Make sure your AWS CLI is configured with a user with admin privileges.

Save the access and secret access keys for your newly created user (with limited permissions) somewhere, you will need them…

##- Packaging the project and preparing it for upload to GameLift

I’ve noticed that when trying to package an Unreal Engine project with both Visual Studio 2017 and 2019 installed, Unreal will default to using the 2017 version. The reason I had both was because I need the 2017 build tools to build the gameliftserversdk dll and lib files. After I did that step, I removed Visual Studio 2017 so that I can continue using Visual Studio 2019 with Unreal Engine.

Make sure to install the Visual C++ redistributable and add them to your packaged build.

Something that the Amazon documentation should have provided was an example install.bat file for the server build. Here’s what it would look like,

vc_redist.x64.exe /q
Engine\Extras\Redist\en-us\UE4PrereqSetup_x64.exe /q

Also, make sure that the plugins are actually in the packaged build. Sometimes they’re not transferred over, so you’ll have to copy and paste them.

Source code for an easy example project to follow can be found here: GitHub - chris-gong/gamelift-example-ue4: Sample project integrating AWS GameLift with Unreal Engine

I hope this helps, good luck everyone!

This is great! Thanks for going through the effort to put this together.

Hi Chris Bro,
I followed your instructions and I m getting this error.

Can you help me.

I built it for linux with ease, installed VM Ware + Ubuntu 19.

Hi, nice guy.

I did what you posted I think plugins were properly compiled though, but I got one problem.

The problem is I couldn’t bring the UI file(UI_Menu.uasset) and Map files(Level_Entry.umap Level_Main.umap Level_Menu.umap) in your project.

** I got a error message when I opened your project file.
Error: CDO Constructor (MenuHUD): Failed to find /Game/UI/Widgets/UI_Menu.UI_Menu_C

I googled how I can get Uasset or Umap files but I couldn’t find a good answer.

Could you solve this?

About a year ago, I made a tutorial about how to integrate an Unreal Engine project with Amazon GameLift. Recently, I decided to update this tutorial to go over more in depth different concepts involving multiplayer development in UE4, GameLift, and other AWS services while correcting issues from the old tutorial as well as following best practices. I try my best to explain things that may not be very well documented, and the hope is that the process for hosting an Unreal Engine server on AWS while using services like GameLift, Cognito, API Gateway, Lambda, and DynamoDb becomes much easier and more beginner-friendly. You can click here to start watching the tutorial.

Here are the different parts of the tutorial series:

Part 1 - Installing Prerequisite files (Visual Studio, Unreal Engine source, etc.)

Part 2 - Buidling the GameLift Server SDK

Part 3 - Uploading a server build to GameLift, making a fleet, and creating a queue

Part 4 - Setting up for FlexMatch, which involves creating a matchmaking rule set, creating a matchmaking configuration, creating an SNS topic for FlexMatch event notifications, creating a table in DynamoDb to store information about specific event notifications, and creating a Lambda function that is subscribed to the SNS topic

Part 5 - Setting up for Cognito, which involves creating a user pool, , adding the Cognito hosted UI to our Unreal Engine game client, and making a request to an API method on API Gateway that will call a Lambda function for getting temporary user pool tokens

Part 6 - Setting up the client service (API Gateway + Lambda), which is an API that contains methods that clients will invoke for interacting with GameLift and other AWS services

Part 7 - Modifying the Unreal Engine client code so that the client can use the Cognito user pool tokens to invoke the client service in a way that will ultimately lead to clients connecting to the game server hosted on AWS

Part 8 - Modifying the Unreal Engine server code so that the server can replicate matchmaking information to the clients, accept player sessions when players connect to the game server, terminate the game session when the “game” is over, handle server process interruptions, handle backfill requests, and more

Part 9 - Remotely accessing a Windows EC2 instance in a GameLift fleet

Part 10 - Cross compiling an Unreal Engine server for Linux on Windows, packaging a Linux server build, uploading that server build to GameLift, creating a fleet out of that build, and remotely accessing a Linux EC2 instance in a GameLift fleet

Part 11 - Going over auto-scaling, specifically target-tracking, in order to try to ensure that there is enough EC2 instance capacity in your fleets for fluctuating player demand/traffic

Part 12 - Going over pricing details and the free tier for the various AWS services used throughout the tutorial

Link to the Unreal Engine Client/Server code: https://github.com/chris-gong/gamelift-example-ue4

Link to the AWS Lambda Backend code: https://github.com/chris-gong/gamelift-example-lambda