Skip to content

Latest commit

 

History

History
109 lines (64 loc) · 6.5 KB

README.md

File metadata and controls

109 lines (64 loc) · 6.5 KB

PlayFab Multiplayer Unreal Game Server Sample

Prerequisites

OPTIONAL:

  • Clone the MpsSamples repository in order to test server allocation by using the MpsAllocatorSample
    • In order to use it, you need to have installed .NET Core

Getting Started

Create a multiplayer game

First, you need to start by creating a multiplayer game with a dedicated server! Thankfully, Unreal has a tutorial to help you make a third person multiplayer game from scratch.

Setting up a dedicated server

Once you have created your game, you can set up a dedicated server by following [these instructions] (https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/HowTo/DedicatedServers/) from Unreal's documentation.

Integrate the Playfab GSDK plugin

Once you've followed this tutorial and created your third person multiplayer game, then you can integrate the Unreal Playfab GSDK Plugin using these instructions.

How to use the packaged server and client

Now that you have a packaged game server, you can also package your game client. Open your Unreal Engine Editor and go to File -> Package Project -> Build Target -> [game name] and then go to File -> Package Project -> Windows (64-bit), and choose what folder you want this file to be saved to.

showing the way to set the build target to the project and package the game client

The packaged game client will be in a folder called "WindowsNoEditor".

Testing Locally using LocalMultiplayerAgent

The following instructions will be for container mode. Because of this, we first need to ensure that our zipped game server has all required system DLLs that are not included in the container image.

To check this, you need to determine the required DLLs by running the ListDLLs tool that is found here.

Once you have included all the necessary DLLs, follow the instructions to set up the Local Multiplayer Agent release that you downloaded and configure the MultiplayerSettings file by following the instructions for running your game server in container mode.

Also, please ensure that the start command for your game server is running the executable found in the binaries folder, not the root file which I discovered through this Playfab Community post.

eg: C:\Assets\YourGame\Binaries\Win64\YourGameServer.exe

Then when your game server is running through LocalMultiPlayerAgent and has a status of Active, you can run your client from the command line with a specific IP address and port as arguments. For example, this command:

.\GameClient.exe 127.0.0.1 -port=30000

would mean that you are running your game client executable, GameClient.exe, to connect to your game server that is on 127.0.0.1 (i.e. local host) through port 30000. You can learn more about command line arguments here.

Testing using Playfab MPSAllocatorSample

With your developer.playfab.com account, create a new TitleID or use an existing one.

This documentation from MPS outlines the process to start deploying VMs for your game server more in depth..

Click on this new TitleID, and go the Multiplayer tab under the Build section.

Screenshot of what the Multiplayer Server tab looks like

Create a new build and make sure that the Server type is "Container". Upload your zipped up game server along with all of the DLLs (the same one you used with LocalMultiplayerAgent) and make sure the mount path and start command are correct.

Set the port to be Unreal's port number, 7777.

Then choose whichever regions you would like and create the new build.

Give the build a few minutes to be deployed.

Once your build is deployed, you are done with handling the "server" portion of the sample, and the next steps will allow us to test using the game client.

First, make sure that you have the MpsSamples repository cloned on your desktop.

Navigate to MpsSamples\MpsAllocatorSample and use the command:

dotnet run

which will launch the MpsAllocatorSample, where you can choose from a menu of 7 API options to call that are frequently used.

Screenshot of what the MpsAllocatorSample menu looks like

To see your build summaries, choose option 2.

To request a new multiplayer server, choose option 1 and make sure you have your BuildID, regions, and players. After entering this information, you should have an active game server.

Screenshot of what a requested server response would be

Using the port and IP address from this server, your players can now run your game client from the command line!

For more Information about MpsAllocatorSample

In order to understand how the MpsAllocatorSample works an a more in-depth manner, you can watch this video that is an introductory level overview of Azure PlayFab Multiplayer Servers, with guided steps to help developers successfully build & deploy a sample game server on PlayFab.

Issues calling Epic Online Services

If you have issues calling Epic Online Services from your Unreal game server, check this file