RealDocs

USubsystem

class Engine Since 4.22
#include "Subsystems/Subsystem.h"
Access: public Specifiers: UCLASSAbstract

Description

Base class for all UE subsystems — auto-instanced singletons that share the lifetime of a specific engine construct (Engine, GameInstance, World, or LocalPlayer). Subclass the appropriate derived type and override `Initialize`/`Deinitialize` instead of a constructor. Access via the owning object's `GetSubsystem<T>()` template.

Signature

UCLASS(Abstract) class USubsystem : public UObject

Caveats & Gotchas

  • Never construct a subsystem manually; the engine creates exactly one instance per owning object.
  • Override `ShouldCreateSubsystem()` to conditionally disable your subsystem (e.g. server-only), but always null-check the result of `GetSubsystem<T>()` when you do.
  • The CDO is queried before instances exist, so avoid reading world/game state inside `ShouldCreateSubsystem`.

Example

Declare and access a GameInstance subsystem C++
UCLASS()
class UMySubsystem : public UGameInstanceSubsystem
{
    GENERATED_BODY()
public:
    virtual void Initialize(FSubsystemCollectionBase& Collection) override;
    virtual void Deinitialize() override;
};

// Access it
UMySubsystem* Sub = GetGameInstance()->GetSubsystem<UMySubsystem>();

Version History

Introduced in: 4.22

Version Status Notes
5.6 stable
5.0 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.