Add a delegate to OnComponentBeginOverlap in C++

What the method to get a delegate for OnbeginOverlap i use to use

XXX->OnComponentBeginOverlap.AddDynamic(XXX::OnBeginOverlap);
But that don’t seem to work anymore. was AddDynamic replaced?
Thanks:

Hello NateP,

This should still work. At what point in your code are you attempting to bind this delegate? Such as, in the constructor, in the OnConstruct function, at BeginPlay, etc.

Thanks for confirmation. I figured out what was going wrong some of my parameter for my Overlap function were not set correctly so the blind was actually working it was just calling the function incorrectly.

For anyone interest here’s the method i use:

In the header

class ASpaceRacerPawn : public APawn
{
	GENERATED_BODY()

    UPROPERTY(BlueprintAssignable, Category = "Collision")
    FComponentBeginOverlapSignature OnComponentOverlap;

protected:
    
    UFUNCTION()
    void OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

}

In the Contructor:

    // creat collistin Component
    CollistionSphere = CreateDefaultSubobject<USphereComponent>(TEXT("Collider0"));
    CollistionSphere->AttachTo(RootComponent);
    CollistionSphere->InitSphereRadius(70.0f);
    CollistionSphere->SetCollisionProfileName("OverlapAll");
    CollistionSphere->bGenerateOverlapEvents = true;
    this->CollistionSphere->OnComponentBeginOverlap.AddDynamic(this, &ASpaceRacerPawn::OnOverlapBegin);

void ASpaceRacerPawn::OnOverlapBegin(class AActor *OtherActor, class UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult)
{
// get cast to collectible
    ACollectibleBase* const Collectible = Cast<ACollectibleBase>(OtherActor);
    
    if (OtherActor == Collectible)
    {
        // do something
    }
}