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.

9 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.

Until now I have always used LineTrace (Raycasting) for stuff like this. But for now I am just following along with the code from the video :smiley:

Your code is much cleaner than that in the video though… Just a little worrying that there is other stuff that might be improved. That said so far I have learned a fair bit of new stuff from the course and haven’t even really begun doing the networking parts yet.

There is a very subtle difference between the two. They may not work as you intend.

1 Like

Privacy & Terms