OnComponentBeginOverlap bugget on worldComposition sublevels

Hi there.

I have a c++ based blueprint with OnComponentBeginOverlap.AddDynamic inside Constructor.

If I drag & drop the blueprint from Content Browser it works, but if I move the actor with Ctrl-C/Ctrl-V , CtrlX-Ctrl-V or “Move Selection to current level” the OnComponentBeginOverlap will not trigger again.

this is my c++ class setup.

AInteractiveObjectActor::AInteractiveObjectActor()
{
 	PrimaryActorTick.bCanEverTick = true;
	
	m_rootMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));

	//Let's make the meshComponent the RootComponent
	RootComponent = m_rootMeshComponent;

	// Setup trigger
	m_trigger = CreateDefaultSubobject<UBoxComponent>(TEXT("TriggerCollider"));
	m_trigger->SetupAttachment(RootComponent);

	m_trigger->OnComponentBeginOverlap.AddDynamic(this, &AInteractiveObjectActor::OnTriggerEnter);
	m_trigger->OnComponentEndOverlap.AddDynamic(this, &AInteractiveObjectActor::OnTriggerExit);

	// Both colliders need to have this set to true for events to fire
	m_trigger->bGenerateOverlapEvents = true;
	 
	// Set the collision mode for the collider
	// This mode will only enable the collider for raycasts, sweeps, and overlaps
	m_trigger->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
}

Hey NomadMonkey,

I’ve tested this and it seems to be working on my end. I’m going to provide you with the code files I’m using to set up my trigger actor, as it’s a bit different than your setup, but more efficient in my opinion. Try using my setup as a base to set up your trigger class and let me know if you’re still running into the same error.

To be clear, I did test this on World Composition sublevels. link text

Let me know if those code files help. Keep in mind that my APlayerCharacter cast is just a cast to my player character, so you’ll need to replace that with your own check if you want to. Also, remember to change all references to my game name to your own in order to allow the files to compile.