Lesson on Constructors, problem with TickComponent

I’m doing the lesson with constructors in the cryptraider section. I simply can’t get the ulog message in the TickComponent to print in the output log, so I have no idea if the trigger component is actually working as it should.

This is my TriggerComponent.h:


#pragma once
#include "CoreMinimal.h"
#include "Components/BoxComponent.h"
#include "TriggerComponent.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class CRYPTRAIDER_API UTriggerComponent : public UBoxComponent
{
    GENERATED_BODY()

public:
    UTriggerComponent();

protected:
    virtual void BeginPlay() override;

public:
    virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};

And this is my TriggerComponent.cpp:


#include "TriggerComponent.h"

UTriggerComponent::UTriggerComponent()
{
    PrimaryComponentTick.bCanEverTick = true;

    UE_LOG(LogTemp, Warning, TEXT("Trigger Component Is Active"));
}

void UTriggerComponent::BeginPlay()
{
    Super::BeginPlay();

    UE_LOG(LogTemp, Warning, TEXT("Trigger Component Is Alive"));
}

void UTriggerComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

    UE_LOG(LogTemp, Warning, TEXT("Trigger Component Is Ticking"));
}

The ulog messages is the constructor and BeginPlay shows up in the output log, but not the ulog message in the TickComponent. Why?

Does it tick if you add it to another actor?

Yes, it does. I added the trigger component to a static mesh pillar and it started to tick. But the BP_SecretWall that’s supposed to have the component does not.

Hm… I added a second trigger to the BP_SecretWall and then it ticks! But when trying to remove the first one I get the message:

“Component “Trigger” has bound events in use! If you delete it then those nodes will become invalid. Are you sure you want to delete it?”

Can someone explain what’s going on here?

Edit: I don’t get this message when deleting other triggers that I add. Can I delete the first one despite the message or will I mess things up?

Privacy & Terms