本文整理汇总了C++中AAIController::MoveToActor方法的典型用法代码示例。如果您正苦于以下问题:C++ AAIController::MoveToActor方法的具体用法?C++ AAIController::MoveToActor怎么用?C++ AAIController::MoveToActor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AAIController
的用法示例。
在下文中一共展示了AAIController::MoveToActor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteTask
EBTNodeResult::Type UBTTask_MoveDirectlyToward::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
const UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent();
FBTMoveDirectlyTowardMemory* MyMemory = reinterpret_cast<FBTMoveDirectlyTowardMemory*>(NodeMemory);
AAIController* MyController = OwnerComp.GetAIOwner();
EBTNodeResult::Type NodeResult = EBTNodeResult::Failed;
if (MyController && MyBlackboard)
{
EPathFollowingRequestResult::Type RequestResult = EPathFollowingRequestResult::Failed;
if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass())
{
UObject* KeyValue = MyBlackboard->GetValue<UBlackboardKeyType_Object>(BlackboardKey.GetSelectedKeyID());
AActor* TargetActor = Cast<AActor>(KeyValue);
if (TargetActor)
{
RequestResult = bDisablePathUpdateOnGoalLocationChange ?
MyController->MoveToLocation(TargetActor->GetActorLocation(), AcceptableRadius, bStopOnOverlap, /*bUsePathfinding=*/false, /*bProjectDestinationToNavigation=*/bProjectVectorGoalToNavigation, bAllowStrafe) :
MyController->MoveToActor(TargetActor, AcceptableRadius, bStopOnOverlap, /*bUsePathfinding=*/false, bAllowStrafe);
}
}
else if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass())
{
const FVector TargetLocation = MyBlackboard->GetValue<UBlackboardKeyType_Vector>(BlackboardKey.GetSelectedKeyID());
RequestResult = MyController->MoveToLocation(TargetLocation, AcceptableRadius, bStopOnOverlap, /*bUsePathfinding=*/false, /*bProjectDestinationToNavigation=*/bProjectVectorGoalToNavigation, bAllowStrafe);
}
if (RequestResult == EPathFollowingRequestResult::RequestSuccessful)
{
const FAIRequestID RequestID = MyController->GetCurrentMoveRequestID();
MyMemory->MoveRequestID = RequestID;
WaitForMessage(OwnerComp, UBrainComponent::AIMessage_MoveFinished, RequestID);
NodeResult = EBTNodeResult::InProgress;
}
else if (RequestResult == EPathFollowingRequestResult::AlreadyAtGoal)
{
NodeResult = EBTNodeResult::Succeeded;
}
}
return NodeResult;
}
示例2: ExecuteTask
EBTNodeResult::Type UBTTask_MoveDirectlyToward::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
const UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent();
FBTMoveDirectlyTowardMemory* MyMemory = reinterpret_cast<FBTMoveDirectlyTowardMemory*>(NodeMemory);
AAIController* MyController = OwnerComp.GetAIOwner();
EBTNodeResult::Type NodeResult = EBTNodeResult::Failed;
if (MyController && MyBlackboard)
{
if (GET_AI_CONFIG_VAR(bEnableBTAITasks))
{
UAITask_MoveTo* AIMoveTask = NewBTAITask<UAITask_MoveTo>(OwnerComp);
if (AIMoveTask != nullptr)
{
bool bSetUp = false;
if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass())
{
UObject* KeyValue = MyBlackboard->GetValue<UBlackboardKeyType_Object>(BlackboardKey.GetSelectedKeyID());
AActor* TargetActor = Cast<AActor>(KeyValue);
if (TargetActor)
{
AIMoveTask->SetUp(MyController, FVector::ZeroVector, TargetActor, AcceptableRadius, /*bUsePathfinding=*/false, FAISystem::BoolToAIOption(bStopOnOverlap));
NodeResult = EBTNodeResult::InProgress;
}
else
{
UE_VLOG(MyController, LogBehaviorTree, Warning, TEXT("UBTTask_MoveDirectlyToward::ExecuteTask tried to go to actor while BB %s entry was empty"), *BlackboardKey.SelectedKeyName.ToString());
}
}
else if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass())
{
const FVector TargetLocation = MyBlackboard->GetValue<UBlackboardKeyType_Vector>(BlackboardKey.GetSelectedKeyID());
AIMoveTask->SetUp(MyController, TargetLocation, nullptr, AcceptableRadius, /*bUsePathfinding=*/false, FAISystem::BoolToAIOption(bStopOnOverlap));
NodeResult = EBTNodeResult::InProgress;
}
if (NodeResult == EBTNodeResult::InProgress)
{
AIMoveTask->ReadyForActivation();
}
}
}
else
{
EPathFollowingRequestResult::Type RequestResult = EPathFollowingRequestResult::Failed;
if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass())
{
UObject* KeyValue = MyBlackboard->GetValue<UBlackboardKeyType_Object>(BlackboardKey.GetSelectedKeyID());
AActor* TargetActor = Cast<AActor>(KeyValue);
if (TargetActor)
{
RequestResult = bDisablePathUpdateOnGoalLocationChange ?
MyController->MoveToLocation(TargetActor->GetActorLocation(), AcceptableRadius, bStopOnOverlap, /*bUsePathfinding=*/false, /*bProjectDestinationToNavigation=*/bProjectVectorGoalToNavigation, bAllowStrafe) :
MyController->MoveToActor(TargetActor, AcceptableRadius, bStopOnOverlap, /*bUsePathfinding=*/false, bAllowStrafe);
}
}
else if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Vector::StaticClass())
{
const FVector TargetLocation = MyBlackboard->GetValue<UBlackboardKeyType_Vector>(BlackboardKey.GetSelectedKeyID());
RequestResult = MyController->MoveToLocation(TargetLocation, AcceptableRadius, bStopOnOverlap, /*bUsePathfinding=*/false, /*bProjectDestinationToNavigation=*/bProjectVectorGoalToNavigation, bAllowStrafe);
}
if (RequestResult == EPathFollowingRequestResult::RequestSuccessful)
{
const FAIRequestID RequestID = MyController->GetCurrentMoveRequestID();
MyMemory->MoveRequestID = RequestID;
WaitForMessage(OwnerComp, UBrainComponent::AIMessage_MoveFinished, RequestID);
NodeResult = EBTNodeResult::InProgress;
}
else if (RequestResult == EPathFollowingRequestResult::AlreadyAtGoal)
{
NodeResult = EBTNodeResult::Succeeded;
}
}
}
return NodeResult;
}