void AShooterAIController::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
APawn *PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
if (LineOfSightTo(PlayerPawn))
{
GetBlackboardComponent()->SetValueAsVector(TEXT("PlayerLocation"), PlayerPawn->GetActorLocation());
GetBlackboardComponent()->SetValueAsVector(TEXT("LastKnownPlayerLocation"), PlayerPawn->GetActorLocation());
}
else
{
GetBlackboardComponent()->ClearValue(TEXT("PlayerLocation"));
}
}
I have a question. I don’t know why I need Investigate. I was told that if it’s out of sight of AI, the player’s location will just be erased. (Maybe I got it wrong)
Both get the player’s location from the if. Get the same value.