Description

Overlap events, such as OnComponentBeginOverlap seem to stop working when the actor is moved to a sub level. This does not occur if the object is deleted and then replaced in the level.

Steps to Reproduce
  1. Open the editor (First Person Template)
  2. Create a new C++ class based on Actor called OverlapActor
  3. Add this code to OverlapActor.h
    UFUNCTION()
    	void OnOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
    
    	UBoxComponent* BoxCollision;
    
    	UStaticMeshComponent* OverlapMesh;
  4. Add this code to OverlapActor.cpp
    AOverlapActor::AOverlapActor()
    {
     	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    	PrimaryActorTick.bCanEverTick = true;
    
    	BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("Box Collision"));
    	SetRootComponent(BoxCollision);
    	BoxCollision->OnComponentBeginOverlap.AddDynamic(this, &AOverlapActor::OnOverlap);
    	BoxCollision->bGenerateOverlapEvents = true;
    
    	OverlapMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
    
    	static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("/Game/Geometry/Meshes/1M_Cube.1M_Cube"));
    	if (Mesh.Succeeded())
    	{
    		OverlapMesh->SetStaticMesh(Mesh.Object);
    	}
    	OverlapMesh->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
    	OverlapMesh->SetWorldScale3D(FVector(.25, .25, .25));
    
    }
    
    void AOverlapActor::OnOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
    {
    	Destroy();
    
    }
  5. Compile
  6. Back in the editor, add an instance of your C++ class to the level
  7. Create a new level
  8. Open the Levels window, and add the new level as a sub level of FirstPersonExample map
  9. PIE and run into the object to ensure overlap is working
  10. Exit PIE
  11. Select the OverlapActor in the level
  12. In the Levels window, right-click on the sub level and select the Move Selected Actors to Level option
  13. Ensure the sub level is set to Always Loaded for its streaming method
  14. PIE and run into the Overlap Actor again

Result: The overlap event no longer works when the object is moved to a sub level

Expected: The overlap event would continue to fire

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-41412 in the post.

3
Login to Vote

Fixed
ComponentUE - Gameplay
Affects Versions4.134.144.15
Target Fix4.18
Fix Commit3611262
Main Commit3628687
Release Commit3643070
CreatedFeb 1, 2017
ResolvedAug 25, 2017
UpdatedJun 11, 2019
View Jira Issue