AActor::NotifyActorEndOverlap

Override Hierarchy

AActor::NotifyActorEndOverlap()

ACharacter::NotifyActorEndOverlap()

Syntax

virtual void NotifyActorEndOverlap
(
    AActor * OtherActor
)

Remarks

Event when an actor no longer overlaps another actor, and they have separated.

Components on both this and the other Actor must have bGenerateOverlapEvents set to true to generate overlap events.

Example Code

MyComponentSpawner.cpp at line 45:

void AMyComponentSpawner::NotifyActorEndOverlap(class AActor* OtherActor)  
{  
    Super::NotifyActorEndOverlap(OtherActor);  

    // When we detect that we are overlapping with another actor we create a new component  
    // above us, this is then removed when an actor leaves.  

    // Other Actor is the actor that triggered the event. Check that is not ourself.  
    if (OtherActor && (OtherActor != this))  
    {  
        //Find all the static mesh components attached to the RootComponent  
        TArray<UStaticMeshComponent*> StaticMeshComponents;  
        for (USceneComponent* Comp : RootComponent->GetAttachChildren())  
        {  
            if (UStaticMeshComponent* MeshComp = Cast<UStaticMeshComponent>(Comp))  
            {  
                StaticMeshComponents.Add(MeshComp);  
            }  
        }  

        //Destroy them  
        for (UStaticMeshComponent* Comp : StaticMeshComponents)  
        {  
            Comp->DestroyComponent();  
        }  
    }  
}

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/Actor.h

Source

Runtime/Engine/Private/Actor.cpp