Component End Overlap not working. C++

I’m trying to set up an Overlap End for a trigger box in c++. RepairStation is the name for this class. Here is the tBox set up.

In RepairStation.h

 UPROPERTY(EditAnywhere)  
	UShapeComponent *tBox;

In RepairStation.cpp
// in constructor

tBox = CreateDefaultSubobject<UBoxComponent>(TEXT("Trigger Box"));  

tBox->bGenerateOverlapEvents = true;  

 tBox->OnComponentEndOverlap.AddDynamic(this, &ARepairStation::TriggerExit);

  RootComponent = tBox;

TriggerExit function:

  void ARepairStation::TriggerExit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp,int32OtherBodyIndex) 
         {
          //printing debug messages here
         }

Below I’ve displayed my working TriggerEnter function.

In RepairStation.h

  UFUNCTION()
	void TriggerEnter(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32         OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);

In RepairStation.cpp

  void ARepairStation::TriggerEnter( class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
 {								 
//Print debug message here
 }

 tBox->OnComponentBeginOverlap.AddDynamic(this, &ARepairStation::TriggerEnter); // in constructor

I currently have a working BEGIN overlap for the same tBox, set-up in the same way, although I pass a different delegate signature. The root problem is that the End Over lap function isn’t working, while the begin overlap does.

Any help would he appreciated.

Thank you.

Hey Dead-Beat-

There is a known issue that binding the OnComponentEndOverlap function does not trigger (UE-29879). You can instead use OnActorEndOverlap, any component that is set to trigger overlap events will then trigger the bound function.

Cheers

Hey ,

Thanks for the quick response. I actually managed to get it working last night. After I made sure all my code was right (to my knowledge) I simply drug a new instance of the class blue print into the editor and everything worked smoothly.

For anyone looking for the correct signature to bind it’s:

OnComponentEndOverlap(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)

8 Likes

It’s amazing. But it still doesn’t work. UE 5.2.1.