求助,关于AI move to函数
为什么AI move to 可以移动到 character所在位置,却不能移动到 Pawn所在的位置 controller moveTO mknmknmk 发表于 2018-5-28 19:43controller moveTO
这是一个函数吗?在蓝图里没有找到 move to 不光可以移动到角色,还可以移动到相应位置,你穿个LOcation
AI move to这个节点是针对拥有characterMovement组件的actor的。 zhu24708 发表于 2018-5-29 08:29
AI move to这个节点是针对拥有characterMovement组件的actor的。
那如果需要pawn达到这个效果,应该添加什么组件?pawn无法添加charactermovement UAIAsyncTaskBlueprintProxy* MyObj = NULL;
AAIController* AIController = Cast<AAIController>(Pawn->GetController());
if (AIController)
{
UWorld* World = GEngine->GetWorldFromContextObjectChecked(WorldContextObject);
MyObj = NewObject<UAIAsyncTaskBlueprintProxy>(World);
FAIMoveRequest MoveReq;
MoveReq.SetUsePathfinding(true);
MoveReq.SetAcceptanceRadius(AcceptanceRadius);
MoveReq.SetReachTestIncludesAgentRadius(bStopOnOverlap);
if (TargetActor)
{
MoveReq.SetGoalActor(TargetActor);
}
else
{
MoveReq.SetGoalLocation(Destination);
}
MoveReq.SetNavigationFilter(AIController->GetDefaultNavigationFilterClass());
FPathFollowingRequestResult ResultData = AIController->MoveTo(MoveReq);
switch (ResultData.Code)
{
case EPathFollowingRequestResult::RequestSuccessful:
MyObj->AIController = AIController;
MyObj->AIController->ReceiveMoveCompleted.AddDynamic(MyObj, &UAIAsyncTaskBlueprintProxy::OnMoveCompleted);
MyObj->MoveRequestId = ResultData.MoveId;
break;
case EPathFollowingRequestResult::AlreadyAtGoal:
World->GetTimerManager().SetTimer(MyObj->TimerHandle_OnInstantFinish, MyObj, &UAIAsyncTaskBlueprintProxy::OnAtGoal, 0.1f, false);
break;
case EPathFollowingRequestResult::Failed:
default:
World->GetTimerManager().SetTimer(MyObj->TimerHandle_OnInstantFinish, MyObj, &UAIAsyncTaskBlueprintProxy::OnNoPath, 0.1f, false);
break;
}
}
return MyObj; 首先有nav mesh bounds volume 和 并且设置nav movement mknmknmk 发表于 2018-5-29 16:41
UAIAsyncTaskBlueprintProxy* MyObj = NULL;
AAIController* AIController = Cast(Pawn->GetController()) ...
多谢,有源代码就很棒了。 mark for use
页:
[1]