Network Levels

Overview

Each replicated property on an AMorpheusActor belongs to one of three network levels (Foreground, Midground or Background) as defined by the user.

Seeing an AMorpheusActor at a specific network level means you can see all replicated properties belonging to that network level and below. For example, if a client is seeing an AMorpheusActor in the midground, it will see all the actor's background and midground properties. This means that every client will see all background properties for every AMorpheusActor in the world at all times.

Each client decides actors' network levels according to a prioritization algorithm. The network levels are filled in order, so that the highest priority actors are in the foreground, the next are in the midground, and the remainder are in the background. The number of actors allowed in foreground and midground is customisable: see Modifying the number in a given network level.

By default, the algorithm prioritizes all actors based on their distance from the client's authoritative Morpheus pawn, but there are some exceptions. For these, see Forcing/prioritizing an entity into the foreground and Modifying the "client origin" for network prioritization .

You can specify the MinimumNetworkLevel of an AMorpheusActor type. The AMorpheusActor will be forced into at least this network level at all times.

Below is a breakdown of each network level, its behavior, limitations and examples.

Foreground

All foreground properties are replicated at 60Hz.

Foreground properties can use most types supported by standard Unreal replication: see Supported types.

Multicast RPCs are only received for actors in the foreground network level.

Depending on the game, each client will likely be able to see on the order of 50-100 actors in the foreground. Foreground properties cost much less bandwidth than midground & background ones. You should only move a property out of foreground if you definitely need it to be more widely visible.

Typical foreground properties include:

  • The player's name.

  • The player's current chat status.

  • A list of the player's teammates.

The server sees every actor in the foreground network level, but only receives foreground property updates at 30Hz.

Midground

All midground properties are replicated at 30Hz.

Background properties can only use a narrow set of types: see Supported types.

Multicast RPCs are not received for actors in the midground network level.

Depending on the game, each client will likely be able to see on the order of 500-1000 actors in the midground.

Typical midground properties include:

  • A higher fidelity quantised position of the actor.

  • The quantised rotation of the actor.

  • The colour index of each player's hat.

Background

All background properties are replicated at 6Hz.

Background properties can only use a narrow set of types: see Supported types.

Multicast RPCs are not received for actors in the background network level.

Because every client sees all background properties in the world, you have to be careful what you mark as a background property. Adding background properties which frequently change value can incur a large bandwidth cost to your game. You should only mark a property as being in the background if it is absolutely essential that it is visible on all clients.

Typical background properties include:

  • A low fidelity quantised position of the actor.

  • An index determining which player character the actor is.

  • The current emote index of each player.

Customizing Network Levels

Modifying the number in a given network level

The number of entities in a given network level can be modified in 2 ways:

  • To modify the number of players in the foreground level, use PlayerClient.Networking.NumInForeground (in the game config)

  • To modify the number of players in the midground, use PlayerClient.Networking.NumInMidground (in the game config)

NOTE: The number in the midground includes all the number in the foreground. Therefore, NumInMidground must be >= NumInForeground. If you want 3 foreground entities, and 3 explicitly midground entities, you would want NumInMidground to be 6.

  • The remaining entities will be placed in the background.

NOTE: Updating the live config will apply to all users.

Via BP

NOTE: This section contains features that were added for release version v29. Some functionality described here won't be present in earlier versions.

We have a helper function on the MorpheusClientConnection class - UpdateBucketMaxEntities. By providing the appropriate bucket name (via GetForegroundBucketName or GetMidgroundBucketName respectively), you can call this method to manually update the bucket's max entites.

(Similarly, we have GetBucketMaxEntities which returns the current value for the relevant networking bucket.)

To get the correct MorpheusClientConnection for the local machine, you can call GetOwningClientConnection on an authoritative Morpheus Actor (e.g. the local player's Morpheus Actor).

NOTE: Calling this method will only apply locally. If you want to update the number for everyone, you will need to either call the method on all machines, or go via the live config approach.

Modifying the "client origin" for network prioritization

NOTE: This section contains features that were added for release version v28. Some functionality described here won't be present in earlier versions.

The client connection uses a "Client Origin Actor" to determine the client's centre for distance related priority calculations. By default this is the authoritative pawn that the client is controlling, but it can be modified.

E.g. if you want to make a "sniper" feature, where you focus in on a distant location, you would want the most high fidelity networked actors to be around your zoomed in location, not your actor's current position.

This client origin actor can be live-updated, by calling the PushClientOriginActor method, providing a new actor to use as the origin location. This makes the new actor trump the default as the origin for the prioritization logic. Once you are done, and want to go back to the default prioritization, call RemoveClientOriginActor, to stop considering your new actor, and return to using the previously set one.

(If you want the client origin to be at a fixed or relative location, the simplest approach would be to spawn an invisible actor, and use it as the Client Origin Actor).

Forcing/prioritizing an entity into the foreground

NOTE: This section contains features that were added for release version v28. Some functionality described here won't be present in earlier versions.

If you want a particular entity to be preferred by the prioritization system regardless of position

This is used e.g. by our "presenters": if you have a VIP player in your game that you want everyone to see at the highest fidelity, you can set it to be prioritized.

There are two ways of achieving this:

  • Via the SetIsForcedIntoForeground method on a morpheus actor:

    • (This will mean that the actor is prioritized on the local machine, and so will trump non-prioritized actors, regardless of position)

  • Via the Capabilities.Morpheus.ForceIntoForeground capability:

    • (This does effectively the same as the approach above under the hood)

    • The capabilities can either be set manaully, or via your Game Roles

NOTE: The forced prioritization here does not override the cap of entities in the foreground network level. If you have e.g. max 30 entities in your foreground, and have 50 prioritized, it won't put all 50 in your foreground. 30 is still the max.

Last updated