Hello,
I am having hard time with OnOverlapEnd. OnOverlapBegin works, and if I leave the area then come back, i can see through logger that collision occurred again, so I am assuming that at some point the Overlap has ended.
In my actor I have:
Header file in public section
UFUNCTION()
virtual void OnOverlapBegin(class UPrimitiveComponent* newComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UFUNCTION()
virtual void OnOverlapEnd(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
In actor constructor I have:
// Enable the generation of overlapping events and assign a function to be run when it happens.
COllisionComp->bGenerateOverlapEvents = true;
// COllisionComp->OnComponentBeginOverlap.AddDynamic(this, &ATV1::OnOverlapBegin);
COllisionComp->OnComponentEndOverlap.AddDynamic(this, &ATV1::OnOverlapEnd);
Note that even if I uncomment the BeginOverlap, I still get BeginOverlap to work!!
In the collision functions for actor:
void ATV1::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
// OtherActor is the actor that triggered the event. Check that is not ourself
if ((OtherActor == nullptr) || (OtherActor == this) || (OtherComp == nullptr))
return;
UE_LOG(MyLog, Warning, TEXT("COllision"));
}
void ATV1::OnOverlapEnd(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
UE_LOG(MyLog, Warning, TEXT("Calling end overlap"));
// OtherActor is the actor that triggered the event. Check that is not ourself
if ((OtherActor == nullptr) || (OtherActor == this) || (OtherComp == nullptr))
return;
UE_LOG(MyLog, Warning, TEXT("End COllision"));
}
So, in summary, there are two problems:
The first problem:
OnOverlapEnd is not called although I can see OnOverlapBegin called multiple times
The second problem:
Even if I comment out the following line, OnOverlapBegin is still called.
// COllisionComp->OnComponentBeginOverlap.AddDynamic(this, &ATV1::OnOverlapBegin);
Any help is appreciated.