Cannot Disable ActorComponent Ticking

Even if you set the ComponentTickFunction to disabled in the constructor it will be activated later during the component activation.

ActorComponent.cpp

void UActorComponent::Activate(bool bReset)
{
	if (bReset || ShouldActivate()==true)
	{
		SetComponentTickEnabled(true);
		SetActiveFlag(true);

		OnComponentActivated.Broadcast(this, bReset);
	}
}

This Activate function is called during component registration on OnRegister ActorComponent.cpp

void UActorComponent::OnRegister()
{

 // Previous code hidden

	if (bAutoActivate)
	{
		AActor* Owner = GetOwner();
		if (!WorldPrivate->IsGameWorld() || Owner == nullptr || Owner->IsActorInitialized())
		{
			Activate(true);
		}
	}
}

So based on that, to completly disable the component tick on constructor you need to set bAutoActivate to false:

UMovementComponent::UMovementComponent()
{
	PrimaryComponentTick.bCanEverTick = true;
	PrimaryComponentTick.bStartWithTickEnabled = false;
	PrimaryComponentTick.SetTickFunctionEnable(false);
	bAutoActivate = false;
}

Hope the explanation helped!

1 Like