I’m pulling my hair out all weekend trying to figure out what I am doing wrong so I made the simplest possible test case and I am still seeing double ticks. Here is what I am doing.
I am trying to make a subsystem derived from UGameInstanceSubsystem that ticks. So Here is what I do.
- Create new empty C++ project (Unreal Engine 5.0.3)
- Create a new Class of type UGameInstanceSubsystem
- Add FTickableGameObject as additional inherited class.
- Implement overrides for Tick() and GetStatId()
- Run the project in PIE and witness double ticks in the logs.
Here is the code I am using for the tickable subsystem
MyGameInstanceSubsystem.h
type or paste#pragma once
#include "CoreMinimal.h"
#include "Subsystems/GameInstanceSubsystem.h"
#include "MyGameInstanceSubsystem.generated.h"
UCLASS()
class MYPROJECT_API UMyGameInstanceSubsystem : public UGameInstanceSubsystem, public FTickableGameObject
{
GENERATED_BODY()
public:
virtual void Tick(float DeltaTime) override;
virtual TStatId GetStatId() const override { return UObject::GetStatID(); };
};
MyGameInstanceSubsystem.cpp
#include "MyGameInstanceSubsystem.h"
void UMyGameInstanceSubsystem::Tick(float DeltaTime)
{
double T = FApp::GetCurrentTime();
UE_LOG(LogTemp, Warning, TEXT("Tick running with current time: %f, delta time: %f, frame: %d"),
T, DeltaTime, GFrameCounter);
}
Log output
Warning LogTemp Tick running with current time: 16875601.640324, delta time: 0.027800, frame: 374
Warning LogTemp Tick running with current time: 16875601.640324, delta time: 0.027800, frame: 374
Warning LogTemp Tick running with current time: 16875601.665518, delta time: 0.025194, frame: 375
Warning LogTemp Tick running with current time: 16875601.665518, delta time: 0.025194, frame: 375
Warning LogTemp Tick running with current time: 16875601.759149, delta time: 0.016667, frame: 380
Warning LogTemp Tick running with current time: 16875601.759149, delta time: 0.016667, frame: 380
I must be doing something wrong but I have no idea what it is.