1. Set up multiserver

To set up offloading you use the multiserver features of SpatialOS. You set up an additional “offloaded” server-worker type to share the computational load of the single main Unreal server-worker. In this guide, you set up a single offloaded server-worker type and one instance of it to compute AI Actors.

In this first section, you set up multiserver functionality for the Example Project’s Control Small map. Multiserver functionality is called “multi-worker” in the Unreal Editor’s UI.

To set up multi-worker, you first need to switch on multi-worker functionality, then you need to define the multi-worker settings in a Blueprint Class. Finally, you must update the map to use your new Blueprint Class.

In the Example Project, some of the offloading set up has been done for you. For full information about offloading set up, see Multiserver offloading.

Switch on the multi-worker functionality

  1. Open the Example Project in the Unreal Editor:
    In File Explorer, locate the UnrealEngine\samples\UnrealGDKExampleProject\Game directory and double-click the GDKShooter Unreal Engine Project file to open the Example Project in the Unreal Editor.
  2. Open the map Control_Small.
    (In the Editor’s Content Browser, open Content > Maps > Control_Small)
  1. In the Editor’s World Settings panel, select Enable Multi Worker.
    (To open the World Settings panel: in the Editor’s Window menu, select World Settings)

Set up multi-worker settings

By following this guide, you define multi-worker settings to include an offloaded server-worker type, called NPC. This server-worker type handles the game’s AI.

This offloaded NPC server-worker type does not use a unique executable. It uses the same executable as the main Unreal server-worker. You are going to set it up as an offloaded server-worker type to compute specific classes of Actor, in this case the game’s AI.

We call each server-worker type a “layer”, so NPC is the offloaded AI server-worker layer. The main Unreal server-worker is its own type and layer: DefaultLayer. DefaultLayer handles everything except the AI.

You define the multi-worker settings in a Blueprint Class. To set up this Blueprint Class:

  1. In File Explorer, navigate to the directory <GameRoot>/Content and create a new directory called Offloading.
    <GameRoot> is the directory that contains your project’s .uproject file and Source directory.
  2. Open the Unreal Editor’s Content Browser.
  3. In the Offloading directory, make a new Blueprint Class and select the parent class SpatialMultiWorkerSettings. Call this new class OffloadingSettings.
    For information on creating a Blueprint Class, see Unreal’s documentation on Blueprint creation.

Image: Select SpatialMultiWorkerSettings as the Parent Class of your new Blueprint Class

  1. Double-click OffloadingSettings to open it.
  2. In the properties for OffloadingSettings, select the + icon next to Worker Layers.
    This adds a new worker layer (worker layer 1). Here you are going to add the new server-worker type called NPC.
    Note that there is already a worker layer 0 called DefaultLayer, which you do not need to change.

Image: The Multi- Worker properties for OffloadingSettings

  1. Expand worker layer 1.
  2. For Name, enter NPC.
  3. Select the + icon next to Actor Classes.
  4. In the drop-down for Actor Class 0, select NPCSpawner.
    This sets up the NPC server-worker type to compute NPCSpawner Actors.
  5. Select the + icon next to Actor Classes.
  6. In the drop-down for Actor Class 1, select Character_NPC.
  7. For Load Balance Strategy, select SingleWorkerStrategy.
    Here you are defining the NPC layer’s load balancing strategy to be one offloaded server-worker instance across the world (the same load balancing strategy as the DefaultLayer that computes the rest of the game world).
  1. From the Blueprint Editor toolbar, select Compile.
  2. Save and close the Blueprint Class.

Update the map

Now you apply the OffloadingSettings Blueprint to the map.

  1. In the Editor's World Settings panel, locate the Multi- Worker section.
  2. In Multi Worker Settings Class, select OffloadingSettings.

That’s all you need to do to offload the AI in the Control_Small map to a dedicated offloaded server-worker instance.

In the next section, you fix some common issues.

2020-08-25 Page updated with editorial review: fixed issue with Character NPC name
2020-08-12 Page updated with editorial review: updated to reflect new offloading settings
2020-06-19 Page updated with editorial review: rewrite for new tutorial
2020-02-24 Page added with editorial review

Updated about a year ago

1. Set up multiserver

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.