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!