Ledger Nano X - The secure hardware wallet
SHARE
TWEET

TargetPointSelection

a guest Apr 10th, 2020 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include "MyBTTaskTargetPointSelection.h"
  3. #include "SoldierAIController.h"
  4. #include "BehaviorTree/BlackboardComponent.h"
  5. #include "SoldierTargetPoint.h"
  6.  
  7. EBTNodeResult::Type UMyBTTaskTargetPointSelection::ExecuteTask(UBehaviorTreeComponent & OwnerComp, uint8 * NodeMemory)
  8. {
  9.     ASoldierAIController* AIController = Cast<ASoldierAIController>(OwnerComp.GetAIOwner());
  10.    
  11.     if (AIController)
  12.     {
  13.         UBlackboardComponent* BlackboardComp = AIController->GetBlackboardComp();
  14.         ASoldierTargetPoint* currentPoint = Cast<ASoldierTargetPoint>(BlackboardComp->GetValueAsObject("LocationToGo"));
  15.        
  16.         TArray<AActor*> AvailableTargetPoints = AIController->GetAvailableTargetPoints();
  17.    
  18.         int32 RandomIndex;
  19.  
  20.         ASoldierTargetPoint* NextTargetPoint = nullptr;
  21.  
  22.         do {
  23.             RandomIndex = FMath::RandRange(0, AvailableTargetPoints.Num() - 1);
  24.             NextTargetPoint = Cast<ASoldierTargetPoint>(AvailableTargetPoints[RandomIndex]);
  25.        
  26.         } while (currentPoint == NextTargetPoint);
  27.  
  28.         BlackboardComp->SetValueAsObject("LocationToGo", NextTargetPoint);
  29.        
  30.         AIController->isPatrolling = true;
  31.  
  32.         return EBTNodeResult::Succeeded;
  33.     }
  34.     return EBTNodeResult::Failed;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top