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?