Behavior Tree - Selector

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.

That’s correct.


Without Investigate the AI would just stop moving when the player is out of sight. The point is to move to where the AI last saw the player.

I understand.Thank you!

Privacy & Terms