20{
22 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Behaviors);
23 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Tasks);
24 UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent();
25 if(BlackboardComp != nullptr)
26 {
27 FVector
Location = FVector::ZeroVector;
28 const AActor* TargetActor = Cast<AActor>(BlackboardComp->GetValueAsObject(
TargetObject.SelectedKeyName));
29 if(TargetActor == nullptr)
30 {
32 }
33 if(TargetActor != nullptr)
34 {
35 Location = TargetActor->GetActorLocation();
36 }
37 if(OwnerComp.GetAIOwner() !=
nullptr && !
Location.IsZero())
38 {
39 const UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetNavigationSystem(OwnerComp.GetAIOwner());
40 if(NavSystem != nullptr)
41 {
43 const bool bFoundPoint = NavSystem->GetRandomReachablePointInRadius(
Location,
Radius, RandomPoint);
44 if(bFoundPoint)
45 {
47 return EBTNodeResult::Succeeded;
48 }
49 }
50 }
51 }
53 return EBTNodeResult::Failed;
54}
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory) override
Definition BTTask_GetNewLocationAround.cpp:19
FBlackboardKeySelector MoveTargetLocation
Definition BTTask_GetNewLocationAround.h:26
FBlackboardKeySelector TargetObject
Definition BTTask_GetNewLocationAround.h:24
float Radius
Definition BTTask_GetNewLocationAround.h:21
static void PrintToLog(const UObject *WorldContextObject, const FString &Message, const bool bWarning=false, const bool bError=false)
Definition BaseHelpersBPLib.cpp:98