4. Zoned servers

Previous: 3. Offloaded servers

Zoned servers are a multiserver, load balancing option with SpatialOS. Zoning works differently from offloading: it involves splitting the world into grid-based areas of authority, with a different server responsible for each area. A server only computes Unreal Actors that are in its area of authority.

Cross-server RPCs

Cross-server RPCs facilitate games running in a multiserver zoning environment. This type of RPC enables a server that does not have authority over an Actor to instruct the server that does have authority over that Actor to update it. This is necessary if you’re using zoned servers because areas of authority mean that one server can’t update every Actor in the game world. A server can only make updates to the Actors in its specified area of authority.

For example, Player 1 and Player 2 are player Actors in different areas of authority.

When Player 1 shoots at Player 2, the server that has authority over Player 1 (server A) invokes a cross-server RPC.

SpatialOS sends this to the server that has authority over Player 2 (server B). Server B then executes the RPC and Player 2’s hat is shot off.

Image: Cross-server RPC - Player 1’s action affects Player 2, even though they are in different areas of authority being updated by different servers.

Image: Cross-server RPC - Player 1’s action affects Player 2, even though they are in different areas of authority being updated by different servers.

You set up a cross-server RPC in the same way you set up any other RPC within Unreal.

Here’s an example of what one might look like:

1
2
UFUNCTION(CrossServer) 
 void TakeDamage(int Damage);

Actor handover

If your game uses zoned servers, you need to make sure that entities can move seamlessly between areas of authority, and the relevant servers can compute them.

In Unreal’s single-server architecture, authority over an Actor stays with the single server; an Actor’s properties never leave the server’s memory. With multiple servers in SpatialOS, authority passes from one server to another as an Actor moves around the game world. Passing authority, known as Actor handover, allows the second server to continue where the first one left off. You set this up by adding the Handover tag to the Actor’s properties.

Image: An AI following a player across the boundary between two servers' areas of authority. To demonstrate Actor handover, the AI changes its material every time authority is handed over.

Next: 5. The Inspector


Last edited on: July 12, 2021 (5638822a)