Enable tick in c++ for an actor

I’m experiencing a weired error when trying to make my actor tick.

This is what my constructor looks like:

AProceduralStreetActor::AProceduralStreetActor(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
	PrimaryActorTick.bCanEverTick = true;
	PrimaryActorTick.bStartWithTickEnabled = true;
	mesh = ObjectInitializer.CreateDefaultSubobject<UProceduralMeshComponent>(this, TEXT("Procedural Street"));
	RootComponent = mesh;

Then I implemented the tick function:

void AProceduralStreetActor::Tick(float DeltaTime)
	UE_LOG(LogTemp, Warning, TEXT("ASD"));
	DrawDebugPoint(GetWorld(), this->endLeftVertex, 20, FColor(255, 0, 0), false, 10.0f);
	DrawDebugPoint(GetWorld(), this->endRightVertex, 20, FColor(128, 0, 0), false, 10.0f);
	DrawDebugPoint(GetWorld(), this->startLeftVertex, 20, FColor(0, 255, 0), false, 10.0f);
	DrawDebugPoint(GetWorld(), this->startRightVertex, 20, FColor(0, 128, 0), false, 10.0f);
	DrawDebugPoint(GetWorld(), this->endLeftVertex + 0.5f * (this->endRightVertex - this->endLeftVertex), 20, FColor(0, 0, 255), false, 10.0f);
	DrawDebugPoint(GetWorld(), this->startLeftVertex + 0.5f * (this->startRightVertex - this->startLeftVertex), 20, FColor(0, 0, 128), false, 10.0f);

… and added the definition to the header file:

virtual void Tick(float DeltaTime) override;

Nevertheless, the function is never called. What am I doing wrong?

Hi padmalcom,

I’ve got exactly the same question. Did you somehow fix it?

Are you just running your game via the editor?
Try - bTickInEditor = true;

Update: that may not be what you’re after… seems to be just for components.

Me too, have you got it fixed?

Tick works as designed and shown above. I only expected it to tick in the editor but ofc it did not. Here is how you make it tick in the editor, too:


Thanks, that works now.

PrimaryActorTick.bCanEverTick = true;

this is out of order. the code for :

void AActor::SetActorTickEnabled(bool bEnabled)
	if (!IsTemplate() && PrimaryActorTick.bCanEverTick)

is checking bCanEverTick before you set it to true.

I don’t think it’s possible