//Initialize senses
PawnSensingComp = CreateDefaultSubobject<UPawnSensingComponent>(TEXT("PawnSensingComp"));
PawnSensingComp->SetPeripheralVisionAngle(30.f);
if (PawnSensingComp) {
PawnSensingComp->OnSeePawn.AddDynamic(this, &AEnemy::OnPlayerCaught);
}
void AEnemy::OnPlayerCaught(APawn* Pawn) {
/*Get a reference to the player controller*/
AEnemyAI* AIController = Cast<AEnemyAI>(GetController());
if (AIController) {
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("You have been caught!"));
AIController->SetPlayerCaught(Pawn);
}
}
Is their a way to check pawn not seen by sensing…