Here, the blackboard key for Update Player Location is set to “LastKnowngePlayerLocation”.
What I said in the lecture was, “It would be inefficient to update LastKnowledgePlayerLocation in Update PlayerLocation.” What do you mean by inefficient…?
And I added a service to the selector.
void UBTService_PlayerLocationIfSeen::TickNode(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory, float DeltaSeconds)
{
Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
APawn *PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
if (PlayerPawn == nullptr)
{
return;
}
if (OwnerComp.GetAIOwner() == nullptr)
{
return;
}
if (OwnerComp.GetAIOwner()->LineOfSightTo(PlayerPawn))
{
OwnerComp.GetBlackboardComponent()->SetValueAsVector(GetSelectedBlackboardKey(), PlayerPawn->GetActorLocation());
}
else
{
OwnerComp.GetBlackboardComponent()->ClearValue(GetSelectedBlackboardKey());
}
}
It’s a service written with these codes. I’m curious. If it’s out of sight, the value of PlayerLocation in the selector disappears. Whether the value of the selector disappears or not, are you just running the Investigate node?