Prepare your project

After you've prepared your project for offloading, you need to set up your game.

When using offloading in your own game, there are some changes to gameplay logic. These are:

  • You set up cross-server RPCs
  • The GDK adds an OnAuthorityGained Event

Cross-server RPCs

To send an RPC to an Actor that is owned by a different server-worker instance, you must use a cross-server RPC. A cross-server RPC enables a server-worker instance that does not have authority over an entity (Actor) to instruct the server-worker instance that does have authority over that Actor to make an update to it.

You can declare cross-server RPCs directly in C++ or through Blueprints.

Find out more: Cross-server RPCs

OnAuthorityGained Event

In offloading, the server-worker instance that spawns an entity (Actor) might not have authority over it. To be able to run initialization logic on the server-worker instance that has authority, the GDK adds an OnAuthorityGained Event.

During your game’s runtime, this event gets called once on the owning server-worker instance for the Actor. This allows you to set up any initialization needed.

To ensure that you can switch between native Unreal networking and SpatialOS networking during game development, if you disable SpatialOS networking, OnAuthorityGained gets called on a server-worker instance immediately after BeginPlay is called.

In the Example Project, the BP_Crashbot class disables the standard “Auto Posses AI” behavior to avoid spawning AI controllers on the wrong server-worker instances. Instead, the project uses OnAuthorityGained to spawn controllers.

Image: Viewing the `OnAuthorityGained` Event in the `BP_CrashBot` Blueprint Class

Image: Viewing the OnAuthorityGained Event in the BP_CrashBot Blueprint Class

2020-06-22 Edited for new offloading implementation
2020-02-26 Page added with editorial review

Updated about a year ago


Now set up your game:

Set up your game

Prepare your project

Suggested Edits are limited on API Reference Pages

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