我似乎誤解了如何在我的組件上實現重疊事件。我創建了一個USphereComponent來跟蹤我的角色。它旨在激發其他演員附近有不到玩家的範圍重疊的事件:USphereComponent and Overlap Events
AScrollsCharacter::AScrollsCharacter()
{
...Redacted irellevant code...
//Create activate trigger radius
USphereComponent* activateRadius = CreateDefaultSubobject<USphereComponent>(TEXT("Activate Radius"));
activateRadius->InitSphereRadius(ACTIVATE_RADIUS);
activateRadius->bGenerateOverlapEvents = true;
activateRadius->SetupAttachment(RootComponent);
activateRadius->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
activateRadius->OnComponentBeginOverlap.AddDynamic(this, &AScrollsCharacter::OnOverlapActivateSphere);
activateRadius->bHiddenInGame = false;
}
void AScrollsCharacter::OnOverlapActivateSphere(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT("We got a collision."));
}
球體組件高度沒有錯誤,並且是在正確的尺寸繪製在屏幕上的半徑。但是,當我將這個半徑帶向遊戲中的其他演員並導致它們重疊時,該事件似乎不會發射。
涉及的所有參與者都將「生成重疊事件」標誌設置爲true。
有人能幫我理解我在這個設置中缺少的東西嗎?
編輯:在編輯器中,球體組件的調試邊界顏色爲橙色,但在遊戲運行時變爲紅色。這種顏色變化是否有意義?
他們是,他們這樣做。我在帖子中表示,所有參與者都將「生成重疊事件」標誌設置爲true,這意味着它們都具有碰撞組件。 – nathan