Hello!
I can’t disable TickComponent function for my ActorComponent. It’s ticking after Stop() call. Why?
Here is my code:
UPatrollingStateComponent::UPatrollingStateComponent()
{
PrimaryComponentTick.bCanEverTick = true;
PrimaryComponentTick.bStartWithTickEnabled = false;
PrimaryComponentTick.SetTickFunctionEnable(false);
bAutoActivate = false;
}
void UPatrollingStateComponent::TickComponent(float DeltaTime,
ELevelTick TickType,
FActorComponentTickFunction * ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
bool active = IsActive();
bool ticking = ThisTickFunction->IsTickFunctionEnabled();
bool isPrimary = ThisTickFunction == &PrimaryComponentTick;
UE_LOG(LogTemp,
Warning,
TEXT("%s - Tick Patrol, %s, %s, %s"),
*FDateTime::Now().ToString(),
active ? TEXT("Active") : TEXT("NOT Active"),
ticking ? TEXT("Enabled") : TEXT("Disabled"),
isPrimary ? TEXT("Primary") : TEXT("NOT Primary"));
}
void UPatrollingStateComponent::BeginPlay()
{
Super::BeginPlay();
PrimaryComponentTick.SetTickFunctionEnable(false);
}
void UPatrollingStateComponent::Start()
{
PrimaryComponentTick.SetTickFunctionEnable(true);
}
void UPatrollingStateComponent::Stop()
{
PrimaryComponentTick.SetTickFunctionEnable(false);
}