블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2797)
Unity3D (853)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)
협업 (61)
3DS Max (3)
Game (12)
Utility (68)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

출처 : http://gpgstudy.com/news/item/1089


Link : http://egohim.blog.me/220043935476

반응형
Posted by blueasa
, |

출처 : http://gpgstudy.com/news/item/1088


링크 : http://www.gamedev.net/page/resources/_/technical/game-programming/pathfinding-and-local-avoidance-for-rpgrts-games-using-unity-r3703

반응형
Posted by blueasa
, |

1) NavMesh Layer 셋팅 방법..




2) NavMesh Layer 셋팅 후 Bake 하는 방법

   (링크 : http://docs.unity3d.com/Documentation/Components/class-NavMeshLayers.html)


NavMesh Layers (Pro only)

The primary task of the navigation system is finding the optimal path between two points in navigation-space. In the simplest case, the optimal path is the shortest path. However, in many complex environments, some areas are harder to move thru than others (for example, crossing a river can be more costly than running across a bridge). To model this, Unity utilizes the concept of cost and the optimal path is defined as the path with the lowest cost. To manage costs, Unity has the concept of Navmesh Layers. Each geometry marked up as Navmesh Static will belong to a Navmesh Layer.

During pathfinding, instead of comparing lengths of potential path segments, the cost of each segment is evaluated. This is a done by scaling the length of each segment by the cost of the navmesh layer for that particular segment. Note that when all costs are set to 1, the optimal path is equivalent to the shortest path.

To define custom layers per project

  • Go to Edit->Project Settings->Navmesh Layers
  • Go to one of the user layers, and set up name and cost
    • The name is what will be used everywhere in the scene for identifying the navmesh layer
    • The cost indicates how difficult it is to traverse the NavMesh layer. 1 is default, 2.0 is twice as difficult, 0.5 is half as difficult, etc.
  • There are 3 built-in layers
    • Default - specifies the cost for everything not otherwise specified
    • Not walkable - the cost is ignored
    • Jump - the cost of automatically generated off-mesh links

To apply custom layers to specific geometry

  • Select the geometry in the editor
  • Pull up the Navigation Mesh window (Window->Navigation)
  • Go to the Object tab, and select the desired Navigation layer for that object
  • If you have Show NavMesh enabled in the Navmesh Display window, the different layers should show up in different colors in the editor.

To tell an agent what layers he can or cannot traverse

  • Go to the NavMeshAgent component of the agent's geometry
  • Modify NavMesh Walkable property
  • Don't forget to set the agent's destination property from a script

Note: Setting the cost value below 1 is not recommended, as the underlying pathfinding method does not guarantee an optimal path in this case

One good use case for using Navmesh Layers is:

  • You have a road that pedestrians (NavmeshAgents) need to cross.
  • The pedestrian walkway in the middle is the preferred place for them to go
  • Set up a navmesh layer with high cost for most of the road, and a navmesh layer with a low cost for the pedestrian walkway.
  • This will cause agents to prefer paths that go thru the pedestrian walkway.

Another relevant topic for advanced pathfinding is Off-mesh links 


반응형
Posted by blueasa
, |

간단한 Nav Mesh 예제

Unity3D / 2012. 11. 21. 13:23

NavMesh를 이용한 간단한 예제 입니다.

방법도 이전에 포스팅 했던 오클루젼 컬링과 같이 간단합니다. (…Bake 시 시간이 좀 더 걸리는 것 같네요.)

 

시작해 보겠습니다.

Path Finding을 하려면 우선밑바닥(Level)이 있어야겠죠?



Terrain을 생성하시거나, Plane 오브젝트를 이용하셔도 무방합니다.

(저는 Plane 오브젝트를 이용해서 간단히 만들어 보았습니다.)

생성하신 Level을 위의 그림과 같이 Navigation Static으로 설정해주세요.



그리고 저는 위의 그림처럼 구성을 해보았는데요장애물이 되는 물체도 Navigation Static으로 설정해 주세요메뉴에서 Window -> Navigation 창을 여시고 Bake를 실행하시면 준비는 끝납니다.

Bake가 완료되면 이제 몇 가지 설정만 더 해주면동작을 하게 되는데요.



길을 찾아갈 대상에 위에 보이는 것과 같이 Nav Mesh Agent 컴포넌트를 추가해줍니다.

그리고 이 오브젝트가 찾아갈 목표지점(Destination)을 지정해주면 되는데요.

목표지점은 스크립팅을 통해서 구현하셔야 합니다.

 

NavMeshAgent navMeshAgent = gameObject.GetComponent<NavMeshAgent>();

navMeshAgent.destination = 목표지점 Transform;

 

Nav Mesh Agent 컴포넌트를 가진 게임 오브젝트에 위와 같은 형태로 목표지점만 추가해주시면 됩니다저의 경우엔 목표지점이 여러 개 였기 때문에, Public 변수로 Transform을 여러 개 받아와서충돌 체크 후에 다음 목표지점으로 변경해주는 방식으로 구현 했습니다.

결과 화면 입니다




출처 : http://korea.unity3d.com/board/index.php?db=knowhow&no=715&mari_mode=view@view


참조 : http://docs.unity3d.com/Documentation/Manual/NavmeshandPathfinding.html

반응형

'Unity3D' 카테고리의 다른 글

Player Settings  (0) 2013.01.15
Layer  (0) 2013.01.15
런타임 중 텍스쳐 교체  (0) 2012.11.20
상체 애니메이션 덧붙이기(AddMixingTransform)  (2) 2012.11.16
Unity3d Android 해상도 설정하기 ( Screen.SetResolution )  (0) 2012.11.14
Posted by blueasa
, |