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")); pTriggerBox->SetupAttachment(RootComponent); pTriggerBox->SetCollisionEnabled(ECollisionEnabled::QueryOnly); pTriggerBox->SetGenerateOverlapEvents(true); pTriggerBox->BodyInstance.SetCollisionProfileName(TEXT("OverlapAll")); // In AMyTrigger::BeginPlay() Super::BeginPlay(); pTriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AMyTrigger::OnBeginOverlap); pTriggerBox->OnComponentEndOverlap.AddDynamic(this, &AMyTrigger::OnEndOverlap); // My overlap functions (copy-pasted from docs): UFUNCTION() void OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); UFUNCTION() 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.