AActor::NotifyActorBeginOverlap

Event when this actor overlaps another actor, for example a player walking into a trigger.

Windows
MacOS
Linux

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

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback