Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to use FinishLatentTask()?

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);
     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.

Product Version: UE 4.18
more ▼

asked Feb 09 '18 at 11:59 AM in C++ Programming

avatar image

3 1 1 3

avatar image XynanXDB Feb 09 '18 at 12:00 PM

The structure on the code is screwed up a bit because I was desperate trying to figure out how to fix it lel.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Never mind, I separate the tasks into 2 BTTaskNode, one for Calculating Next AI Location another one for Moving there

more ▼

answered Feb 09 '18 at 03:24 PM

avatar image

3 1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question