x

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"

UBTTaskNode adding completion event?

Hey guys, I am attempting to create a custom black board task in C++. In my Execute task function I successfully do what I want to do, but the function completes instantly.

 EBTNodeResult::Type UBTT_MoveToRandomLocation::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
 {
     
     FVector randomVector = FMath::VRand();
 
     randomVector.Normalize();
 
     randomVector *= FMath::RandRange(MinimumWanderRadius, MaximumWanderRadius);
 
     UAITask_MoveTo* currentOperation = nullptr;
 
     switch (WanderMode)
     {
     case EWanderMethod::FromSpecifiedPoint:
         currentOperation = UAITask_MoveTo::AIMoveTo(OwnerComp.GetAIOwner(), m_wanderCenter + randomVector);
         break;
     case EWanderMethod::FromCurrentPoint:
         m_wanderCenter = m_wanderCenter = OwnerComp.GetAIOwner()->GetPawn()->GetActorLocation();
         currentOperation = UAITask_MoveTo::AIMoveTo(OwnerComp.GetAIOwner(), m_wanderCenter + randomVector);
         break;
     case EWanderMethod::FromSpawnPoint:
         currentOperation = UAITask_MoveTo::AIMoveTo(OwnerComp.GetAIOwner(), m_wanderCenter + randomVector);
         break;
     default:
         break;
     }
 
     return EBTNodeResult::Succeeded;
 }

I want to wait until currentOperation is complete before saying my task is done but cannot figure out how to do that outside of introducing a busy wait loop. Any ideas?

Product Version: UE 4.13
Tags:
more ▼

asked Feb 17 '17 at 12:27 AM in C++ Programming

avatar image

Zamithal
58 13 12 17

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Instead of EBTNodeResult::Succeeded you need to return EBTNodeResult::InProgress (or something similar, I'm away from my sources ;) ). Also, consider returning "failure" result if something goes wrong.

Cheers,

--mieszko

more ▼

answered Feb 17 '17 at 02:22 AM

avatar image

MieszkoZ STAFF
7.3k 223 57 412

avatar image Zamithal Feb 17 '17 at 04:43 AM

Wouldn't I just be stuck in InProgress forever then? how does the behavior tree know when the event is ever completed?

avatar image acxsasx Mar 28 '17 at 01:30 PM

You have to setup conditions to tell it when it is completed. I had to setup a custom delay task using a timer. I return InProgress until the timer fires which then returns Succeeded.

(comments are locked)
10|2000 characters needed characters left
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