AActor::NotifyActorBeginOverlap

Override Hierarchy

AActor::NotifyActorBeginOverlap()

ACharacter::NotifyActorBeginOverlap()

Syntax

virtual void NotifyActorBeginOverlap
(
    AActor * OtherActor
)

Remarks

Event when this actor overlaps another actor, for example a player walking into a trigger. For events when objects have a blocking collision, for example a player hitting a wall, see 'Hit' events.

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

Example Code

MyComponentSpawner.cpp at line 19:

void AMyComponentSpawner::NotifyActorBeginOverlap(class AActor* OtherActor)  
{  
    Super::NotifyActorBeginOverlap(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))  
    {  
        // Make a location to spawn a new component  
        FTransform SpawnLocation = GetTransform();  
        SpawnLocation.AddToTranslation(FVector(0.f, 0.f, 200.f));  

        //Spawn a new component  
        USceneComponent* SpawnedComp = SpawnNewComponent(UStaticMeshComponent::StaticClass(), SpawnLocation);  

        //Set our new component to use our mesh  
        UStaticMeshComponent* MeshComp = Cast<UStaticMeshComponent>(SpawnedComp);  
        MeshComp->SetStaticMesh(MyMesh);  
        MeshComp->RegisterComponent();  
    }  
}

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/Actor.h

Source

Runtime/Engine/Private/Actor.cpp