Hello everyone,
I just came across interesting problem related to overlap/hit events. I have a C++ based blueprint, and I set up everything in the blueprint. After that, I needed a hit event and added in the code. After compiling the code, the event wasn’t being fired. I created a new blueprint which is based on the same code and the event in the new blueprint was working, however, the event in the old blueprint wasn’t still working. Same thing happened when I needed to add overlap events as well, and I solved the problem by creating a new blueprint. Is this a kind of bug in UE 4.20? Or is there any solution to fix this? Because I don’t want to set up everything again and again when I need to add an event.
EDIT: This problem is not related to collision channels. Events work fine if I create them in the blueprint
// h file
UFUNCTION()
void OnHit(UPrimitiveComponent* hitComponent, AActor* otherActor, UPrimitiveComponent* otherComp, FVector normalImpulse, const FHitResult& hit);
UFUNCTION()
void OnBeginOverlap(UPrimitiveComponent* overlappedComp, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult &sweepResult);
// cpp file
//...
Mesh1->SetSimulatePhysics(true);
Mesh1->SetGenerateOverlapEvents(true);
Mesh1->SetNotifyRigidBodyCollision(true);
Mesh1->OnComponentHit.AddDynamic(this, &AClass::OnHit);
//...
Mesh2->SetGenerateOverlapEvents(true);
Mesh2->OnComponentBeginOverlap.AddDynamic(this, &AClass::OnBeginOverlap);