본문 바로가기
[ CODING STUDY ]/》언리얼엔진5 실습

언리얼엔진5 Ai move to (Ai 랜덤이동, Ai 공격)

by MRG 2024. 4. 6.
728x90
반응형

 

▣ Enemy ai를 만들 Character 클래스를 생성합니다. 

 

 

▣ BP_EnemyAi로 이름을 지정하고 메뉴 들어가서 Mesh를 지정하고 PawnSensing 컴포넌트를 추가합니다. 

 

 

▣ Event Graph에서 Add Custom Event를 추가하여 Follow Player, RandomMove 두 개 Event를 생성합니다.

Follow Player는 플레이어를 발견하면 플레이어를 따라가는 이벤트

RandomMove는 플레이어를 발견하지 않는 상태에서는 랜덤으로 이동하는 이벤트입니다. 

 

 

▣ Ai move to를 검색하여 Ai move to 노드도 추가합니다. 

 

 

https://dev.epicgames.com/documentation/ko-kr/unreal-engine/BlueprintAPI/AI/AIMoveTo?application_version=5.3

 

AI MoveTo

AI MoveTo

dev.epicgames.com

 

 

▣ 위에 이미지처럼 플레이어를 감지하면 플레이어를 Follow를 하고 공격하는 노드를 완성합니다. 

 

▣ Ai Move To 노드 

Pawn : Ai Pawn

Destination :  목적지
Target Actor : 타깃 액터  
Acceptance Radius  : 수용 반경
Stop on Overlap : 겹치면 중지

 

 

▣ 위에 버튼을 눌러 Nav를 검색하여 Nav Mesh Bounds Volume을 레벨에 추가합니다. 

 

https://dev.epicgames.com/documentation/en-us/unreal-engine/modifying-the-navigation-mesh-in-unreal-engine

 

Modifying the Navigation Mesh in Unreal Engine

Describes the different ways you can modify Navigation Mesh generation in Unreal Engine.

dev.epicgames.com

 

 

▣ Show에서 Navigation을 체크하고 크기를 조절하여 AI 이동 경로를 지정합니다. 

 

 

▣ 플레이를 하고 Ai에 감지되면 플레이어를 따라오는 걸 확인합니다. 

 

 

▣ GetRandomReachablePointInRadius노드는 : Origin에서 도달할 수 있는 Radius 내 임의의 위치를 ​​찾습니다.

 

▣ 위에 이미지처럼 노드를 완성하여 랜덤으로 이동하는 AI 노드를 완성합니다. 

 

 

https://docs.unrealengine.com/4.27/en-US/API/Runtime/NavigationSystem/AAbstractNavData/GetRandomReachablePointInRadius/

 

AAbstractNavData::GetRandomReachablePointInRadius

Finds a random location in Radius, reachable from Origin

docs.unrealengine.com

 

 

 

▣ AI 이동속도는 Character Movement에서 수정합니다.

 

 

▣ 플레이를 하고 랜덤으로 이동하는 AI를 확인합니다. 

728x90
반응형

댓글