Tick function not firing in Actor Component driven class. Here is my class code of the driven class named MyActorComponent.
#include "BlankTestProject.h"
#include "MyActorComponent.h"
// Sets default values for this component's properties
UMyActorComponent::UMyActorComponent(const FObjectInitializer& ObjectInitializer )
: Super(ObjectInitializer)
{
if (GetOwner() != nullptr)
{
RegisterComponent();
GEngine->AddOnScreenDebugMessage(1, 3.0f, FColor::Red, TEXT("ActorComponent Constructor"));
}
PrimaryComponentTick.TickGroup = TG_PrePhysics;
PrimaryComponentTick.SetTickFunctionEnable(true);
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
//UE_LOG(LogTemp, Log, TEXT("Log"));
// ...
}
// Called when the game starts
void UMyActorComponent::BeginPlay()
{
Super::BeginPlay();
GEngine->AddOnScreenDebugMessage(2, 3.0f, FColor::Red, TEXT("ActorComponent BeginPlay"));
// ...
//if(IsRegistered())
//RegisterComponentTickFunctions(true);
}
// Called every frame
void UMyActorComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
GEngine->AddOnScreenDebugMessage(3, 3.0f, FColor::Blue, TEXT("ActorComponent Tick"));
// ...
}