You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
778 B
28 lines
778 B
// Copyright Zelle Games
|
|
|
|
|
|
#include "MoveToRandomSpot.h"
|
|
|
|
#include "AIController.h"
|
|
#include "NavigationSystem.h"
|
|
|
|
EBTNodeResult::Type UMoveToRandomSpot::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
|
|
{
|
|
bNotifyTick = 1;
|
|
FNavLocation Loc;
|
|
UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetCurrent(GetWorld());
|
|
NavSystem->GetRandomReachablePointInRadius(OwnerComp.GetAIOwner()->GetPawn()->GetActorLocation(), 8000, Loc);
|
|
OwnerComp.GetAIOwner()->MoveToLocation(Loc.Location);
|
|
return EBTNodeResult::InProgress;
|
|
}
|
|
|
|
void UMoveToRandomSpot::TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
|
|
{
|
|
TimeSinceExecute += DeltaSeconds;
|
|
if(TimeSinceExecute > 2)
|
|
{
|
|
FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded);
|
|
}
|
|
}
|
|
|