Triggering breakpoints on SpawnActor

I’m trying to spawn an actor (AMyTrigger), which has a UBoxComponent for overlap events, from another actor (AMyMainActor). But when I call SpawnActor (in AMyMainActor), engine code triggers some breakpoints and if I skip all of them my overlap events will not work.

The simplified version of my code:

// In AMyMainActor:
AMyTrigger* pMyTriggerActor = GetWorld()->SpawnActor<AMyTrigger>();

// In AMyTrigger constructor:
pTriggerBox = CreateDefaultSubobject<UBoxComponent>(MakeUniqueObjectName(this, UBoxComponent::StaticClass(), "Trigger"));

// In AMyTrigger::BeginPlay()

pTriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AMyTrigger::OnBeginOverlap);
pTriggerBox->OnComponentEndOverlap.AddDynamic(this, &AMyTrigger::OnEndOverlap);

// My overlap functions (copy-pasted from docs):
void OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

void OnEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

I can provide more code just tell me what you need to see because I can’t understand why it’s so hard.


Are you building from source engine?
Can you provide any more information on where the code break, check the callstack or just the error message :slight_smile:

Old Tips that might not matter anymore:
I normally have a habit of checking for a nullptr in the constructor after “CreateDefaultSubobject”.