UWorldSubsystem
#include "Subsystems/WorldSubsystem.h"
Access: public
Specifiers: UCLASSAbstract
Description
Subsystem base class tied to a single `UWorld` — created when the world initializes and destroyed when it tears down. Ideal for per-world services such as spatial queries, runtime data registries, or gameplay systems that must reset on level change. Retrieved via `UWorld::GetSubsystem<T>()`.
Signature
UCLASS(Abstract) class UWorldSubsystem : public USubsystem Caveats & Gotchas
- • A new instance is created for every world (including PIE worlds), so data is not shared across worlds.
- • Override `DoesSupportWorldType()` to restrict to specific world types and skip preview/editor worlds.
- • Use `OnWorldBeginPlay` rather than `Initialize` if you need actors to already exist in the world.
Examples
Access from an actor C++
if (UMyWorldSubsystem* Sub = GetWorld()->GetSubsystem<UMyWorldSubsystem>())
{
Sub->RegisterTarget(this);
} Tickable variant C++
// Inherit UTickableWorldSubsystem and implement Tick(float DeltaTime)
UCLASS()
class UMyTickSubsystem : public UTickableWorldSubsystem
{
GENERATED_BODY()
virtual void Tick(float DeltaTime) override;
virtual TStatId GetStatId() const override { RETURN_QUICK_DECLARE_CYCLE_STAT(UMyTickSubsystem, STATGROUP_Tickables); }
}; See Also
Tags
Version History
Introduced in: 4.22
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.0 | stable | — |
Feedback
Was this helpful?