虚幻Unreal - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(83评价)
价格: 3049.00元

关于UNavigationSystem过时的问题,针对当前此课程给出的解决方案:

#include "AIEnemy.h"
#include "NavigationSystem.h"

void AAIEnemy::OnPossess(APawn *InPawn) {
    Super::OnPossess(InPawn);
    Bot = Cast<AEnemy>(InPawn);
}

void AAIEnemy::OnMoveCompleted(FAIRequestID RequestID, const FPathFollowingResult &Result) {

}

void AAIEnemy::SearchNewPoint() {
    // 获取导航系统
    UNavigationSystemV1* NavMesh = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
    if (NavMesh) {
        const float SearchRadius = 1000.0f; // 搜索半径
        FNavLocation RandomPt; // 随机位置

        // 判断是否能找到该位置
        const bool bFound = NavMesh->GetRandomReachablePointInRadius(Bot->GetActorLocation(), SearchRadius, RandomPt);
        if (bFound) {
            // 移动到获取的随机位置点
            MoveToLocation(RandomPt);
        }
    }
}

在Build.cs源文件中,找到

PublicDependencyModuleNames代码,在数组中添加“NavigationSystem”
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "NavigationSystem" });

 

[展开全文]
满天飞舞的蒲公英 · 2019-04-28 · 0

AttachTo方法过时,需要使用以下代码形式:

CollectableMesh->AttachToComponent(BaseCollisionComponent, FAttachmentTransformRules::KeepRelativeTransform);

 

[展开全文]
满天飞舞的蒲公英 · 2019-04-26 · 0