TickComponent not called (c++)

Hi,

I have a UActorComponent, here is my constructor

USwitchComponent::USwitchComponent()
{
	PrimaryComponentTick.bCanEverTick = false;
	PrimaryComponentTick.bStartWithTickEnabled	= true;
	PrimaryComponentTick.TickGroup = TG_PrePhysics;
	
	bAutoRegister	= true;
	bWantsInitializeComponent = true;
	bAutoActivate	= true;
}

But TickComponent not got called, I add everything I read in the AnswerHUB.
The component is attached to a staticmesh (I set to moveable too), the Component is not a SceneComponent.

Any ideas? I try all in my knowledge.

thanks

I think you shoud change:

PrimaryComponentTick.bCanEverTick = true;

1 Like

I had a similar problem but in my case, In BeginPlay() method, I forgot to call Super::BeginPlay() and Tick Stoped working.

1 Like

In my case this was caused by a Hot-reload issue.
Solution was to recreate a variable

Symptoms: The BeginPlay was called. If I added the component via blueprint it worked, but Tick method was not called if I add the component via c++ .

Solution:
I created duplicated the variable name and creation with 2 and it worked

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Input)
UPlayerAimingComponent* PlayerAimingComponent2;

// ... 
PlayerAimingComponent2 = CreateDefaultSubobject<UPlayerAimingComponent>(TEXT("PlayerAimingComponent2"));

double-check that BeginPlay is called.

I had the same problem. No Component Ticking. I solved it with this code in Actor’s Constructor:

PlayerStateComponent = CreateDefaultSubobject<UPlayerStateComponent>(TEXT("PlayerStateComponent"));
PlayerStateComponent->SetMobility(EComponentMobility::Movable);  // In case if you add it to a ACharacter/APawn
PlayerStateComponent->SetupAttachment(RootComponent);
PlayerStateComponent->RegisterComponent();
PlayerStateComponent->PrimaryComponentTick.bCanEverTick = true;

It has worked out after restarting an editor.

Open The YourActorComponet Blueprint, Let TickBlueprintEvent Node Link Anyone Node, Fix It.