Skip to content

Subsystems

Use a subsystem for state that belongs to an Unreal world, game instance, local player, engine, or editor. Unreal creates and manages the instance. For example, use a world subsystem to keep a score shared by actors in one level.

Create and use a world subsystem

Create a Python class with WorldSubsystem as its parent, or add the example to a registered module under Python/scripts/.

import ue


@ue.uclass
class LevelScore(ue.WorldSubsystem):
    points: int = ue.uproperty(0, category="Score")

    @ue.ufunction
    def add_points(self, amount: int) -> int:
        self.points += amount
        return self.points

Look up the subsystem from a gameplay callback. Pass the actor or world that owns the state you want. In Play In Editor, that context selects the correct play world.

def award_points(actor: ue.Actor) -> None:
    score = ue.SubsystemBlueprintLibrary.get_world_subsystem(
        LevelScore, context_object=actor
    )
    if score is not None:
        ue.log(f"Level score: {score.add_points(10)}")

Choose a lifetime

Base class Scope
ue.WorldSubsystem One Unreal world. Use it for level state.
ue.GameInstanceSubsystem One game instance. Use it for state that should survive map changes.
ue.LocalPlayerSubsystem One local player. Use it for local-player services.
ue.EngineSubsystem One engine instance. Use it for services shared across worlds.
ue.EditorSubsystem The editor. Call it from editor tooling.

Use post_init to initialize Python state and post_deinit for cleanup tied to the subsystem lifetime. For state that must reach clients, use an actor with replicated properties.