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.
UFUNCTION()
void OnOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UBoxComponent* BoxCollision;
UStaticMeshComponent* OverlapMesh;
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(); }
Result: The overlap event no longer works when the object is moved to a sub level
Expected: The overlap event would continue to fire
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-41412 in the post.
3 |
Component | UE - Gameplay |
---|---|
Affects Versions | 4.13, 4.14, 4.15 |
Target Fix | 4.18 |
Created | Feb 1, 2017 |
---|---|
Resolved | Aug 25, 2017 |
Updated | Jun 11, 2019 |