Download

UPawnSensingComponent, how do you do it ?

I added this component to the AIController.cpp in Constructor

PawnSensingComp = CreateDefaultSubobject<UPawnSensingComponent>(TEXT(“PawnSensingComp”));

To BeginPlay

PawnSensingComp->OnSeePawn.AddDynamic(this, &AMyAIController::OnPawnSeen);

The following function is now executed when the AI sees an enemy and fills the variable in the blackboard with the location of the seen pawn, so far so good, my problem or my question, if the AI sees no enemy, should he do something, is this possible somehow? Or how do you deal with the visual behavior of AI ? Thanks a lot

void AMyAIController::OnPawnSeen(APawn* SeenPawn)
{
GetBlackboardComponent()->SetValueAsVector(TEXT(“LetzterOrt”), SeenPawn->GetActorLocation());
}

Did you write UFUNCTION() macro on your OnPawnSeen function in the header?