Alternative way to handle overlapping

Sometimes, we don’t need all these parameters when we are checking the overlap. If we don’t we can simply override two functions:

virtual void NotifyActorBeginOverlap(AActor* OtherActor) override;
virtual void NotifyActorEndOverlap(AActor* OtherActor) override;

Both of them can be found inside actor.h header and they are public functions. Then you just implement them in .cpp

void APPlatformTrigger::NotifyActorBeginOverlap(AActor * OtherActor)
{
	UE_LOG(LogTemp, Warning, TEXT("Overlapped"));
}

void APPlatformTrigger::NotifyActorEndOverlap(AActor * OtherActor)
{
	UE_LOG(LogTemp, Warning, TEXT("End Overlapped"));
}

Cheers.

7 Likes

Simple is better. I was trying to get the BeginComponentOverlap and EndComponentOverlap but couldn’t figure them out.

void BeginComponentOverlap(const FOverlapInfo & OtherOverlap,  bool bDoNotifies)
void EndComponentOverlap(const FOverlapInfo & OtherOverlap, bool bDoNotifies, bool bSkipNotifySelf)

Thank you so much, I was following along and adding extra features, and then ran into an issue that this helped solve!
I added another capsule component to the character (to detect walls) thus resulting in the double firing of activation and deactivation. Since this function takes into account separate actors rather than the components that make them up, it was a perfect fix to this issue.

Thanks again.