TickComponent is not working

BeginPlay works, but TickComponent and UTriggerComponent creators don’t. Why?

// Fill out your copyright notice in the Description page of Project Settings.


#include "TriggerComponent.h"

//생성자
//라이브 코딩에서 생성자를 추가하더라도 적용되지 않는 경우가 있으니 에디터를 닫고 Run Build Task를 꼭 진행하라
UTriggerComponent::UTriggerComponent()
{
    PrimaryComponentTick.bCanEverTick = true;
    UE_LOG(LogTemp, Display,TEXT("Trigger constructing"));
}

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

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

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

    UE_LOG(LogTemp, Display,TEXT("Tick is suss"));
    TArray<AActor*> Actors;
    //이 액터가 겹치는 액터(구성요소와 겹치는 모든 구성요소) 목록을 반환합니다.
    //.num을 이용해 몇개의 액터가 들어있는지 확인 할 수 있다.
    //겹치는 액터가 하나 이상일때 작동하게 만들 수 있다.
    // GetOverlappingActors(Actors);

    // if(Actors.Num()>0){
    //     FString ActorName = Actors[0]->GetActorNameOrLabel();
    //     UE_LOG(LogTemp,Display,TEXT("OverLapping : %s"),*ActorName)
    // }
}
// Fill out your copyright notice in the Description page of Project Settings.

#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:
	// Called when the game starts
	virtual void BeginPlay() override;

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

};

image


Sometimes tickComponent works when nothing is touched, sometimes it doesn’t. Why?

Have you tried removing the trigger component from the actor and adding a new one?


Are you saying to delete the trigger and try adding it again?

Yes.


I removed the trigger and added it back and the problem was fixed. Thank you so much. What’s the reason for this problem?

Sometimes things can get a little out of sync with the C++ code and blueprint.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms