Multiserver Shooter tutorial

1: Set up

Step 1: Check you have the prerequistes

Before following the Multiserver Shooter tutorial, you need to have followed:

Once you have done this, you are ready to get going with the Multiserver Shooter tutorial by following the steps below.

Let’s get started!

Step 2: Clone the Unreal GDK Third Person Shooter repository

Clone the Unreal GDK Third Person Shooter repository and checkout the tutorial branch using one of the following commands:

HTTPS: git clone -b tutorial
SSH: git clone -b tutorial

This repository contains a version of Unreal’s Third Person template that has been ported to the SpatialOS GDK. It includes a character model with a gun and hit detection logic.

Note: A completed version of this tutorial is available in the tutorial-complete branch.

Step 3: Clone the GDK into the Plugins directory

  1. Navigate to UnrealGDKThirdPersonShooter\Game and create a Plugins directory.
  2. In a terminal window, change directory to the Plugins directory and clone the Unreal GDK repository using one of the following commands:
HTTPS: git clone
SSH: git clone

The GDK’s default branch (GitHub documentation) is release. This means that, at any point during the development of your game, you can get the latest release of the GDK by running git pull inside the UnrealGDK directory. When you pull the latest changes, you must also run git pull inside the UnrealEngine directory, so that your GDK and your Unreal Engine fork remain in sync.

Note: You need to ensure that the root folder of the Unreal GDK repository is called UnrealGDK so its path is: UnrealGDKThirdPersonShooter\Game\Plugins\UnrealGDK\.

Step 4: Build dependencies

In this step, you’re going to build the Unreal GDK’s dependencies.

  1. Open File Explorer, navigate to the root directory of the GDK for Unreal repository (ThirdPersonShooter\Plugins\UnrealGDK\...), and double-click Setup.bat. If you haven’t already signed into your SpatialOS account, the SpatialOS developer website may prompt you to sign in.
  2. In File Explorer, navigate to the ThirdPersonShooter directory, right-click ThirdPersonShooter.uproject and select Generate Visual Studio Project files.
  3. In the same directory, double-click ThirdPersonShooter.sln to open it with Visual Studio.
  4. In the Solution Explorer window, right-click on ThirdPersonShooter and select Build.
  5. When Visual Studio has finished building your project, right-click ThirdPersonShooter and select Set as StartUp Project.
  6. Press F5 on your keyboard or select Local Windows Debugger in the Visual Studio toolbar to open your project in the Unreal Editor.
    Visual Studio toolbar
    Image: The Visual Studio toolbar

  7. In the Unreal Editor, on the GDK toolbar, open the Schema drop-down menu and select Schema (Full Scan).
    Image: On the GDK toolbar in the Unreal Editor, select Schema (Full Scan)
  8. Select Snapshot to generate a snapshot.
    Image: On the GDK toolbar in the Unreal Editor, select Snapshot

Step 5: Deploy the project locally

In this section you’ll run a local deployment of the project. As the name suggests, local deployments run on your development machine (you will run a cloud deployment later in this tutorial).

  1. In the Unreal Editor, on the Unreal toolbar, open the Play drop-down menu.
  2. Under Multiplayer Options, enter the number of players as 2.
  3. Enter the number of servers as 2.
  4. Ensure the box next to Run Dedicated Server is checked.

    Image: The Unreal Engine Play drop-down menu, with Multiplayer Options and New Editor Window (PIE) highlighted

  5. From the Unreal toolbar’s Play drop-down menu, select SpatialOS Settings… to open the SpatialOS Editor Settings panel.
  6. In the panel, under the Launch drop-down menu, select the following drop-down menus: Launch configuration file description > Workers > 0.
  7. Locate the Rectangle grid row count field beolow this and set it to 2.
  8. In the Unreal Editor, in the SpatialOS GDK toolbar, select Start (the green play icon). This opens a terminal window and runs the spatial local launch command, which starts the SpatialOS Runtime.
  9. It’s ready when you see SpatialOS ready. Access the inspector at http://localhost:21000/inspector.
  10. From the Unreal Editor toolbar, select Play to run the game. This starts two SpatialOS server-worker instances and two SpatialOS client-worker instances locally, in your Unreal Editor.
    The two server-worker instances are acting as two Unreal servers and the two client-worker instances are acting as two Unreal game clients (as would be used by two game players).
    (You can find out about workers in the glossary.)

Notice that when players shoot each other, their health does not go down. It’s not much fun with no skin in the game is it? Let’s fix the health system.

> Next: 2: Replicate health changes

2019-04-30 Page updated with limited editorial review

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums