UDN
Search public documentation:
DevelopmentKitGemsCreatingADynamicNavMeshObstacleKR
English Translation
日本語訳
中国翻译
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
日本語訳
中国翻译
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
동적인 내비게이션 메시 장애물 만들기
문서 변경내역: James Tan 작성. 홍성진 번역.
2011년 3월 UDK 버전으로 최종 테스팅, PC 와 iOS 호환
개요
관련 토픽
동적 내비게이션 메시 장애물
class DynamicNavMeshObstacle extends NavMeshObstacle; // 가능한 모양 목록 enum EShape { EShape_None, EShape_Square, EShape_Rectangle, EShape_Circle }; // 내비 메시 장애물 모양 var PrivateWrite EShape ShapeType; // EShape_Square 에 사용 var PrivateWrite float Width; // EShape_Square 및 EShape_Rectangle 에 사용 var PrivateWrite float Height; // EShape_Circle 에 사용 var PrivateWrite float Radius; // EShape_Circle 에 사용 var PrivateWrite int Sides; // 장애물을 액터의 로테이션에 맞춤? var bool AlignToRotation; simulated function PostBeginPlay() { // 디폴트 PostBeginPlay 함수 생략 Super(Actor).PostBeginPlay(); } function SetAsSquare(float NewWidth) { if (NewWidth > 0.f) { ShapeType = EShape_Square; Width = NewWidth; } } function SetAsRectangle(float NewWidth, float NewHeight) { if (NewWidth > 0.f && NewHeight > 0.f) { ShapeType = EShape_Rectangle; Width = NewWidth; Height = NewHeight; } } function SetAsCircle(float NewRadius, float NewSides) { if (NewRadius > 0.f && NewSides > 0) { ShapeType = EShape_Circle; Radius = NewRadius; Sides = NewSides; } } event bool GetObstacleBoudingShape(out array<vector> Shape) { local Vector Offset; local int i, Angle; local Rotator R; if (ShapeType == EShape_Square) { if (AlignToRotation) { // 우상단 구석 Offset.X = Width; Offset.Y = Width; Shape.AddItem(Location + (Offset >> Rotation)); // 우하단 구석 Offset.X = -Width; Offset.Y = Width; Shape.AddItem(Location + (Offset >> Rotation)); // 좌하단 구석 Offset.X = -Width; Offset.Y = -Width; Shape.AddItem(Location + (Offset >> Rotation)); // 좌상단 구석 Offset.X = Width; Offset.Y = -Width; Shape.AddItem(Location + (Offset >> Rotation)); } else { // 우상단 구석 Offset.X = Width; Offset.Y = Width; Shape.AddItem(Location + Offset); // 우하단 구석 Offset.X = -Width; Offset.Y = Width; Shape.AddItem(Location + Offset); // 좌하단 구석 Offset.X = -Width; Offset.Y = -Width; Shape.AddItem(Location + Offset); // 좌상단 구석 Offset.X = Width; Offset.Y = -Width; Shape.AddItem(Location + Offset); } return true; } else if (ShapeType == EShape_Rectangle) { if (AlignToRotation) { // 우상단 구석 Offset.X = Width; Offset.Y = Height; Shape.AddItem(Location + (Offset >> Rotation)); // 우하단 구석 Offset.X = -Width; Offset.Y = Height; Shape.AddItem(Location + (Offset >> Rotation)); // 좌하단 구석 Offset.X = -Width; Offset.Y = -Height; Shape.AddItem(Location + (Offset >> Rotation)); // 좌상단 구석 Offset.X = Width; Offset.Y = -Height; Shape.AddItem(Location + (Offset >> Rotation)); } else { // 우상단 구석 Offset.X = Width; Offset.Y = Height; Shape.AddItem(Location + Offset); // 우하단 구석 Offset.X = -Width; Offset.Y = Height; Shape.AddItem(Location + Offset); // 좌하단 구석 Offset.X = -Width; Offset.Y = -Height; Shape.AddItem(Location + Offset); // 좌상단 구석 Offset.X = Width; Offset.Y = -Height; Shape.AddItem(Location + Offset); } return true; } else if (ShapeType == EShape_Circle && Sides > 0) { // 면의 수로 정의된 각 'slice' 각도 구하기 Angle = 65536 / Sides; // 로테이션에 맞춰져 있다면, 시작 지점으로 로테이션 사용 R = (AlignToRotation) ? Rotation : Rot(0, 0, 0); // 반경 설정 Offset.X = Radius; Offset.Y = 0.f; // 각 면에 대해... for (i = 0; i < Sides; ++i) { // 왼편 지점에 추가 Shape.AddItem(Location + (Offset >> R)); // 다음편에 증가 R.Yaw += Angle; } return true; } return false; } defaultproperties { }
DynamicNavMeshObstacle 사용하기
var DynamicNavMeshObstacle PlacementObstacle; function PostBeginPlay() { Super.PostBeginPlay(); PlacementObstacle = Spawn(class'DynamicNavMeshObstacle'); PlacementObstacle.SetAsCircle(96, 8); }
function Tick(float DeltaTime) { Super.Tick(DeltaTime); ForEach TraceActors(class'Actor', HitActor, HitLocation, HitNormal, CachedMouseWorldOrigin + CachedMouseWorldDirection * 65536.f, CachedMouseWorldOrigin,,, class'Actor'.const.TRACEFLAG_Bullet) { if (HitActor.bWorldGeometry) { PlacementObstacle.UnRegisterObstacle(); PlacementObstacle.SetLocation(HitLocation); PlacementObstacle.RegisterObstacle(); break; } } }
