Did you ever got a component to tick?

I am struggling with a new component, just created a c++ class based on ActorComponent.
I inserted a UE_LOG into the tick.
I do not get one log message at all
BeginPlay is called once when i log it, the tick never.

Any ideas how to get this tick ?

.cpp:
#include “BattleTank.h”
#include “TestComponent.h”

// Sets default values for this component’s properties
UTestComponent::UTestComponent()
{
// 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.
bWantsBeginPlay = true;
PrimaryComponentTick.bCanEverTick = true;

// ...

}

// Called when the game starts
void UTestComponent::BeginPlay()
{
Super::BeginPlay();

// ...

}

// Called every frame
void UTestComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
UE_LOG(LogTemp, Warning, TEXT(“TickComponent4”))
// …
}

.h

#pragma once

#include “Components/ActorComponent.h”
#include “TestComponent.generated.h”

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BATTLETANK_API UTestComponent : public UActorComponent
{
GENERATED_BODY()

public:
// Sets default values for this component’s properties
UTestComponent();

// Called when the game starts
virtual void BeginPlay() override;

// Called every frame
virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;

};

I had this exact same issue, and it drove me crazy. For me, deleting and readding the component on its parent fixed it.

Hi Carson,
i will try that the next days. Thanks for the advice.

Had the same problem, deleting and readding the component fixed it.

Thanks a lot, it was driving me crazy!

1 Like

I’m in the middle of this. Will try delete/add tonight or tomorrow as about to head out to a church function. But the online documentation for the TickComponent function says, in addition to bcanevertick, or whatever it is, being set to true, the component has to be “registered”. So maybe deleting/readding causes the registration to run again and update it. So I bet it’s a registration issue. Maybe Ben never had the issue because he often commits/restores from Github between lectures (which would probably also rerun the registration), but I did notice in the lecture when he added the TickComponent method, his logs never showed it actually ticking.

And it is confirmed, deleting and re-adding tankcomponent does the job:

Remove the TankAimingComponent from tank in the blueprint and put it back on. You then have to re-wire it in a couple places.

Apparently, according to the TickComponent documentation, the component has to be “registered” before it ticks. Removing and replacing the TankAimingComponent has the effect of re-registering it. Ben’s code probably ​worked in later lectures because he often restores from Github between lectures, and rebuilds it all.

I ran to the same issue in UE5.4, where the component tick doesn’t work even though it was enabled both at the component and parent’s constructors.

I found an easier solution by adding the following line in the parent/owner’s BeginPlay() or PostInitializeComponents() function override:

MyComponent->PrimaryComponentTick.bCanEverTick = true;

So my code in the character’s CPP file:

void AMyCharacter::PostInitializeComponents()
{
    Super::PostInitializeComponents();

    MyComponent->PrimaryComponentTick.bCanEverTick = true;

}

Privacy & Terms