我似乎误解了如何在我的组件上实现重叠事件。我创建了一个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