캐릭터를 따라갈 수 있도록 설정된 ATriggerSphere가 있으며 다른 액터와 겹치는 부분에 반응합니다. 그래서 같이이 작업을 수행하려고 해요 :TriggerSphere 및 다른 Actor와의 겹침 처리?
void AScrollsCharacter::BeginPlay()
{
// Call the base class
Super::BeginPlay();
//Create activate trigger radius
activateRadiusTrigger = GetWorld()->SpawnActor<ATriggerSphere>(ATriggerSphere::StaticClass(),GetActorLocation(), GetActorRotation());
activateRadiusTrigger->SetActorHiddenInGame(false);
USphereComponent* colSphere = (USphereComponent*) activateRadiusTrigger->GetCollisionComponent();
colSphere->SetSphereRadius(ACTIVATE_RADIUS);
colSphere->bGenerateOverlapEvents = true;
colSphere->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
colSphere->OnComponentBeginOverlap.AddDynamic(this, &AScrollsCharacter::OnOverlapActivateSphere);
}
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."));
}
void AScrollsCharacter::Tick(float deltaSeconds)
{
Super::Tick(deltaSeconds);
//Set the radius trigger to follow the player
activateRadiusTrigger->SetActorLocation(GetActorLocation());
}
OnOverlapActivateSphere는하지만, 충돌 호출 받고있는 것으로 보이지 않는다. 캐릭터가이 구체 안에 있기 때문에 나는 그것을 무시하는 방아쇠를 아직 말하지 않았다. 나는 메시지가 모든 눈금을 인쇄 할 것으로 기대한다. 내가 잘못 이해했거나 누락 되었습니까? 감사!
응답 해 주셔서 감사합니다. 1 단계와 2 단계에서 조언을 얻었고이를 반영하기 위해 위의 코드를 약간 수정했습니다. 슬프게도, 배우들이 ** 서로 겹치도록 ** 보장하여 내 문제를 해결하지 못했습니다. 여전히 중복 이벤트를 등록하지 않습니다. – nathan
@nathan 게임 중에 "Show Collision"콘솔 명령을 사용하여 트리거 구가 예상 한 위치에 있는지 확인 했습니까? –
예. 구체는 화면에 그려지며 절대적으로 다른 배우와 물리적으로 겹칩니다. – nathan