How to make a Tickable Object

By default, some objects in Unreal are tickable and some are not. UUserWidget has a NativeTick function, but a lot of other UWidget subclasses are not. Similarly when implementing Subsystem singletons I often want to make them tickable.

Making something tickable is a lot easier than I first thought. If your class implements the FTickableGameObject interface it will automatically be ticked! It does not have to be a subclass of UObject, it can just be a regular struct or class.

This sample code should be all you need to get started:


#pragma once

#include "CoreMinimal.h"
#include "Tickable.h"

class FMyTickableThing : public FTickableGameObject
	// FTickableGameObject Begin
	virtual void Tick( float DeltaTime ) override;
	virtual ETickableTickType GetTickableTickType() const override
		return ETickableTickType::Always;
	virtual TStatId GetStatId() const override
	virtual bool IsTickableWhenPaused() const
		return true;
	virtual bool IsTickableInEditor() const
		return false;
	// FTickableGameObject End

	// The last frame number we were ticked.
	// We don't want to tick multiple times per frame 
	uint32 LastFrameNumberWeTicked = INDEX_NONE;


#include "MyTickableThing.h"

void FMyTickableThing::Tick( float DeltaTime )
	if ( LastFrameNumberWeTicked == GFrameCounter )

	// Do our tick
	// ...

	LastFrameNumberWeTicked = GFrameCounter;