Programming Subsystems and Replication
Article written by Alex K.
The engine’s Programming Subsystems provide lightweight and easy to use extension points for core engine classes. When using these subsystems for a multiplayer game or other networked project, these may seem like a good place to include networking related functionality, such as server/client-only code or replicated properties. Unfortunately, programming subsystems are not designed to work with the engine’s networking systems, and there are certain problems that can arise when trying to do so. This article will try to provide some context on common problems with using the programming subsystems for networking, as well as ways to workaround these issues.
Programming subsystems do not directly support replication, as the objects they extend are not replicated. This means it is not possible to replicate properties or call RPCs through a subsystem.
When these subsystems are initialized, it is also possible that certain values may not be available as expected for server/client instances. For example, a common problem is that the instance’s NetMode may not be correct when certain subsystems are initialized. This can cause issues if a subsystem has code that should only be run on a server or on a client during initialization. Furthermore, this makes it very difficult to control whether a subsystem is only spawned on a client or server, as during initialization there is not a good way to tell which one the instance will be.
Generally, it is recommended to use a separate actor (or a component/subobject owned by an actor) instead of a subsystem for any networking functionality that subsystem needs. For example, replicated properties and RPCs can be routed through a separate replicated actor before being applied to the subsystem. Server or client specific functionality may be moved to an actor or object that is only spawned on that respective instance, or this functionality can be placed behind a check for the actor’s role or authority.
See more on the Knowledge Base.