How to use OnActorBeginOverlap c++ code?

You need to define the function you are going to use for the OnOverlapBegins.

Here is an example:

[h]



    // Overlap
    UFUNCTION( )
    void BeginOverlap(UPrimitiveComponent* OverlappedComponent, 
                      AActor* OtherActor, 
                      UPrimitiveComponent* OtherComp, 
                      int32 OtherBodyIndex, 
                      bool bFromSweep, 
                      const FHitResult &SweepResult );


[cpp]



AMyActor::AMyActor()
{
     Collider->OnComponentBeginOverlap.AddDynamic( this, &AMyActor::BeginOverlap );
}

void AMyActor::BeginOverlap(UPrimitiveComponent* OverlappedComponent, 
                                AActor* OtherActor, 
                                UPrimitiveComponent* OtherComp, 
                                int32 OtherBodyIndex, 
                                bool bFromSweep, 
                                const FHitResult &SweepResult )
{
   // Overlap
}


5 Likes