GameLift: Assign User to Policy

After creating our Access Policy (from this guide), we’ll create a new user and assign that user to our newly created Policy.

Click on “Users” then “Add user

Give your user a Username and AccessType “Programmatic Access

Click on Attach existing policies directly, then search for the policy we just created

Click on Next: Tags, and skip this step. Move on to “Create User

User successfully created!

I highly encourage you to “Download .csv” to save your credentials to a file, otherwise you will NOT be able to retrieve these credentials again!

GameLift: Access Policy

Creating an Access Policy

Click on Create Policy

Select “JSON” type policy

Copy-paste this codeblock into the text editor

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "gamelift:*",
            "Resource": "*"
        }
        ]
}

The result should look like this, click on “Review Policy” when done

Give our Policy a name, we’ll use “GameLiftFullAccess” in this example, click on “Create Policy” when done

GameLiftFullAccess policy created

GameLift: Initializing Client

Prerequisites

Before we can initialize and use GameLift, we need to create Access keys that we use to Identify ourselves with Amazon GameLift.

Follow these tutorials on how to create an Access Policy & Assign a user to our Policy.

  1. Creating an Access Policy
  2. Create a new user and assign our Policy

Initializing GameLift Client

Using our newly created Policy & User credentials we can Initialize GameLift inside Unreal Engine.

Using GameLift

After you’ve “Created a GameLift Object” we can start accessing GameLift functionality!
You can find all GameLift functions by searching for GameLift in the Context menu

You can use utility function “GetGameLiftObject” to get the last created GameLiftObject, if you create a new object then this function will return that object. You can store a reference to the object instead if you want to use multiple GameLift Objects.

Finding Sessions

Joining a Session

More Examples

Check out the downloadale Example Project

GameLift: Dedicated Server

Requirements

  • A working Unreal Engine Dedicated Server, see the Unreal Engine Documentation on how to set this up
  • Own a copy of the GameLiftServer Plugin
  • Move the AwsGameLiftServer plugin folder to YourProject\Plugins

Initializing a GameLift Server

We must first create a Server Object, this can be done via blueprint or native c++. If you want the ability to override Gamelift server events, you can create a new child class of parent type “GameLiftServerObject” (see example image below)

Overridable functions (optional)

Constructing the Server Object

We’re going to construct & initialize our game server inside our GameInstance blueprint. Search for “Construct object from class” in the context window.

Initializing the server

Implement the two events inside our GameInstance, called Init and Shutdown. Implement the Initialization as demonstrated below.

When the game instance is constructed the GameServer will start talking with GameLift and wait for events from AWS GameLift Servers.

Note: Calling the InitSDK in a non-server environment will do nothing, it’s been disabled and will only run on dedicated servers.

Accepting Player Sessions (Optional)

The AWSCore::GameLiftServer plugin comes with a GameMode that you can use to make it easier to Accept player sessions, it has a overridable blueprint event called “PreLogin” that you can use to grab PlayerIds from.

Reparent your GameMode blueprint to GameLiftServerGameMode

How to accept player sessions using the PreLoginEvent

How to include PlayerId when connecting

You can send your PlayerId to the server by appending it to your Options string, this will make it available to the server when connecting and using it in the example above.

Custom Listen Port

You can run your Server.exe executable with the -Port=XXXX to have both GameLift and your GameServer to listen on an alternative port.