C++ constructor created collision boxes don't work

Hello, I’d love some input on this issue I’ve been dealing with for days now. I have found several questions referencing a similar problem, but based on the responses to those (link to one of the posts I viewed), everything should be working fine.

The problem: UBoxComponents added to my actor with CreateDefaultSubobject do not trigger overlap events. (in general, their collision settings - whatever they are - don’t seem to work

Example the works: Creating a BP from my C++ actor and adding a box component, copying the properties from the C+±created component, and binding an event in task graph to OnComponentBeginOverlap, works normally.

What I’m doing: I’m trying to add trigger volumes to a static interact-able actor in the level.

More context: I tried binding the OnComponentBeginOverlap of the C+±created box component in the BP task graph, but that also doesn’t work. Even calling GetOverlappingActors on the C+±created box in the actor tick function returns en empty set every time. As mentioned, the properties of both the C+±created box and the BP-created box are the same. This is the code I wrote to create the component in c++:

Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
SetRootComponent(Mesh);

Box = CreateDefaultSubobject<UBoxComponent>(TEXT("TriggerArea"));
Box->SetSimulatePhysics(false);
Box->InitBoxExtent(FVector(100, 100, 100));
Box->SetupAttachment(Mesh);
Box->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);
Box->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
Box->SetCollisionObjectType(ECC_WorldDynamic);
Box->SetGenerateOverlapEvents(true);

Is this a bug? Am I missing something obvious?

EDIT: I have tried to SetCollisionResponseToAllChannels(Overlap), and pretty much did exactly what this says.

Thanks for your time,
Dan

Are you triggering an overlap event in BP or in C++? Because if it’s in BP, then everything’s working fine (except for line 8), it triggers when a pawn enters the box.

With what should this actor interact? A pawn, a linetrace, a projectile, …?

I am trying to catch the overlap both in BP and in C++ via On component overlap.AddDynamic(…)
None of those work.
The trigger box should interact with the player capsule, but I’ve also tried OverlapAllDynamic as the chosen collision profile.

Creating an actor with only what you showed, works fine to me. You must be doing something extra.

I tried creating a new actor, copying the code over, and now it works. No idea what this was, and I don’t even want to know. If anyone experiences similar black magic, I guess do what I did. :confused: