How can I tick a TickableWorldSubsystem?

I have tried overriding UTickableWorldSubsystem::Tick but the UE_LOG in my implementation is not called. Am I doing this incorrectly? Unfortunately I cannot find any documentation on this.

Header:

#pragma once

#include "CoreMinimal.h"
#include "Subsystems/WorldSubsystem.h"
#include "MyTickableWorldSubsystem.generated.h"

UCLASS()
class EXAMPLE_API UMyTickableWorldSubsystem : public UTickableWorldSubsystem
{
    GENERATED_BODY()
    
    virtual void Initialize(FSubsystemCollectionBase& Collection) override;
    virtual void Deinitialize() override;
    
    virtual void Tick(float DeltaTime) override;
};

cpp:

#include "MyTickableWorldSubsystem.h"

void UMyTickableWorldSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
    UE_LOG(LogTemp, Warning, TEXT("Subsystem Initialized!"));
}

void UMyTickableWorldSubsystem::Deinitialize()
{
    UE_LOG(LogTemp, Warning, TEXT("Subsystem De-initialized!"));
}

void UMyTickableWorldSubsystem::Tick(float DeltaTime)
{
    UE_LOG(LogTemp, Warning, TEXT("Subsystem Tick!"));
}
1 Like

I may be a bit late to answer here, but in case anyone else ever wonders:

The reason why your subsystem does not tick can be found in UTickableWorldSubsystem. This implements all the functions for the FTickableGameObject interface, including the function IsAllowedToTick which you cannot override. Looking at the implementation, you can see that this function returns the variable bInitialized (and if it isnt a template). This variable is private, so you cant access it from the child class.
In order to set up your class to actually tick, the Initialize function fo the UTickableWorldSubsystem needs to be called. So you need to add a Super::Initialize(Collection) to your implementation of that function.

TL;DR: UTickableWorldSubsystems need to call Super::Initialize in their initialize function to be allowed to tick

2 Likes

Add this to the code:

public:
	virtual TStatId GetStatId() const override
	{
		return GetStatID();
	}

Works for me.

6 Likes

Another way :

TStatId UL0LevelSubsystem::GetStatId() const
{
	RETURN_QUICK_DECLARE_CYCLE_STAT(ULoadingScreenManager, STATGROUP_Tickables);
}
2 Likes