HI, everyone. I’m having problem to set a task’s EBTNodeResult from InProgress to Succeeded. I made the AI move to a location when the AI is too close to the player.
EBTNodeResult::Type UBTTask_MoveBack::ExecuteTask(UBehaviorTreeComponent & OwnerComp, uint8 * NodeMemory)
{
AAICharacterController* AICon = Cast<AAICharacterController>(OwnerComp.GetAIOwner());
FVector AILoc = AICon->GetCharacter()->GetActorLocation();
FVector NextAILoc;
if (AICon) {
UBlackboardComponent* blackboardComp = Cast<UBlackboardComponent>(AICon->GetBlackboardComp());
AActor* playerKey = Cast<AActor>(blackboardComp->GetValueAsObject("Player"));
FVector minAndMaxDistance = blackboardComp->GetValueAsVector("minandMaxDistance");
NextAILoc = AILoc + (AICon->GetCharacter()->GetActorForwardVector() * -1 * 200.0f);
//x Distance between AI and Player
//float deltaDistance = FVector::Dist(AICon->GetCharacter()->GetActorLocation(), playerKey->GetActorLocation());
UKismetSystemLibrary::DrawDebugLine(GetWorld(), AILoc, NextAILoc, FLinearColor::Red, 5.0f, 10.0f);
AICon->MoveToLocation(NextAILoc);
}
return EBTNodeResult::InProgress;
}
But the problem is the Task stays InProgress. Is there anyway to set it to Succeeded when AI reached target location? I found out the FinishLatentTask(), but I dont know when and how to call? Please help, I’m a noob.