Tick is never called, even though bCanEverTick is set to true

Here’s the code:

TestActor.h:

UCLASS()
class ATestActor : public AActor
{
	GENERATED_UCLASS_BODY()

	virtual void Tick(float DeltaTime) override;
	
};

TestActor.cpp:

ATestActor::ATestActor(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	PrimaryActorTick.bCanEverTick = true;
}

void ATestActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT("Tick"));
	}
}

The “Tick”-text is never displayed on the screen, which would mean that the Tick()-function never gets called. Why? I enabled bCanEverTick and it’s still not ticking…

You also need to add:

PrimaryActorTick.bStartWithTickEnabled = true;
PrimaryActorTick.bAllowTickOnDedicatedServer = true;

You can omit the second one if you don’t want actor to tick on server.

Thanks! This worked!

Thanks! This is a life saver! was about to pull my hair out lol.