728x90
반응형
.h
UFUNCTION(BlueprintCallable)
void MoveToTarget(class AProject_AACharacter* Target);
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "AI")
class AAIController* AIController;
.cpp
void AEnemy::BeginPlay()
{
Super::BeginPlay();
AIController = Cast<AAIController>(GetController());
}
void AEnemy::MoveToTarget(class AProject_AACharacter* Target)
{
if (AIController)
{
FAIMoveRequest MoveRequest;
MoveRequest.SetGoalActor(Target);
MoveRequest.SetAcceptanceRadius(10.0f);
FNavPathSharedPtr NavPath;
AIController->MoveTo(MoveRequest, &NavPath);
// /** 경로 보여줌
// auto PathPonints = NavPath->GetPathPoints();
// for (auto Point : PathPonints)
// {
// FVector Location = Point.Location;
// UKismetSystemLibrary::DrawDebugSphere(this, Location, 25.f, 8, FLinearColor::Red, 10.f, 1.5f);
// }
// */
}
}
.build.cs
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "UMG", "AIModule" });
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
.build.cs 에 "AIModule" 꼭 추가
728x90
반응형
'언리얼 엔진 > C++' 카테고리의 다른 글
언리얼엔진 C++ AnimInstance (0) | 2021.02.10 |
---|---|
FTimerHandle (0) | 2021.02.09 |
소켓에 컴포넌트 붙이기 (0) | 2021.02.08 |
캐릭터 이동 (0) | 2021.02.07 |
Unreal Engine 4 OnOverlap (0) | 2021.02.06 |