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:
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
Step 3: Clone the GDK into the
- Navigate to
UnrealGDKThirdPersonShooter\Gameand create a
- In a terminal window, change directory to the
Pluginsdirectory and clone the Unreal GDK repository using one of the following commands:
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
UnrealGDKso its path is:
Step 4: Build dependencies
In this step, you’re going to build the Unreal GDK’s dependencies.
- 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.
- In File Explorer, navigate to the ThirdPersonShooter directory, right-click
ThirdPersonShooter.uprojectand select Generate Visual Studio Project files.
- In the same directory, double-click
ThirdPersonShooter.slnto open it with Visual Studio.
- In the Solution Explorer window, right-click on ThirdPersonShooter and select Build.
- When Visual Studio has finished building your project, right-click ThirdPersonShooter and select Set as StartUp Project.
- Press F5 on your keyboard or select Local Windows Debugger in the Visual Studio toolbar to open your project in the Unreal Editor.
Image: The Visual Studio toolbar
- 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)
- Select Snapshot to generate a snapshot.
Image: On the GDK toolbar in the Unreal Editor, select Snapshot
Step 5: Deploy the project locally
- In the Unreal Editor, on the Unreal toolbar, open the Play drop-down menu.
- Under Multiplayer Options, enter the number of players as 2.
- Enter the number of servers as 2.
- 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
- From the Unreal toolbar’s Play drop-down menu, select SpatialOS Settings… to open the SpatialOS Editor Settings panel.
- In the panel, under the Launch drop-down menu, select the following drop-down menus: Launch configuration file description > Workers > 0.
- Locate the Rectangle grid row count field beolow this and set it to 2.
- 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 launchcommand, which starts the SpatialOS Runtime.
- It’s ready when you see
SpatialOS ready. Access the inspector at http://localhost:21000/inspector.
- 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.
2: Replicate health changes
2019-04-30 Page updated with limited editorial review