OnComponentBeginOverlap

Hey every time I build and run the editor it crashes because of this line

            CollisionComp = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("SphereComp"));
    	CollisionComp->InitSphereRadius(15.0f);
    //// this line right below 
    	CollisionComp->OnComponentBeginOverlap.AddDynamic(this, &AEnemyClass::OnOverlap);
    
    
    	RootComponent = CollisionComp;

I did set it up in the header. Any idea what is going on? All I want to do is check the begin of the overlap.

void OnOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

Thank you

Hi, is this code inside AEnemyClass? If so, check log, it should give some useful information in this case.

In case anyone else has the same issue, I figured out that the OnComponentBeginOverlap (and all other delegates) search for the functions you set up by string, so you need to add UFUNCTION() above the declaration of your function in the header so that it exposes its name to the engine, like so:

// In the Actor's header file.
UFUNCTION()
void OnBeginOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);