Search Unity

Is it possible to define restricted area in unity navMesh?

Discussion in 'Editor & General Support' started by bigbat, Jun 27, 2013.

  1. bigbat

    bigbat

    Joined:
    Jul 20, 2011
    Posts:
    37
    Hi to all
    In my current project i use unity navmesh for generating walkable area on my terrain and my npc's use NavMeshAgent for pathfinding and navigating in game,and it works good.I want know is it possible to mark some areas of my terrain as unwalkable (e.g. lakes or deep rivers)?
    I use an empty game object with a spherecollider component surrond restricted area but npc's still pass that area.
    I will be grateful for any help.
     
  2. Deleted User

    Deleted User

    Guest

    Absolutely, you should have under the Navigation > Object tab a Navigation Layer drop down.

    Simply select the meshes you wish to make "unwalkable", select Unwalkwable on the drop down and rebake.

    I presume maybe you want to use empty game objects, but that won't do much since navmeshes depend on meshes or colliders to build on. Best bet is create temporary planes to define the unwalkable areas, and then disable them once the nav mesh is baked.
     
  3. bigbat

    bigbat

    Joined:
    Jul 20, 2011
    Posts:
    37
    thanks for reply
    I will try your solution soon.
     
  4. bigbat

    bigbat

    Joined:
    Jul 20, 2011
    Posts:
    37
    Thanks again .i test your solution and it's result was great and acceptable.
     
  5. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Is it possible for part of Unity terrain?
     
  6. Stankiem

    Stankiem

    Joined:
    Dec 4, 2013
    Posts:
    115
    Careful not to allow your players or other objects which are rigidbodies to cut holes in your navmesh, it eats up lots of resources. If an object can be changed each frame, Unity will update it each frame for the navmesh update.
     
  7. sarahnorthway

    sarahnorthway

    Joined:
    Jul 16, 2015
    Posts:
    78
    It's still in beta, but you can now use NavMeshModifierVolume from Unity's GitHub project NavMeshComponents to mark sections of a terrain as not walkable. To do this:
    • Install the components from https://github.com/Unity-Technologies/NavMeshComponents

    • Add a NavMeshModifierVolume to your scene and set the area type to Not Walkable

    • Add a NavMeshSurface to your scene (defaults all scene objects to walkable)

    • Bake via the NavMeshSurface, NOT Unity's built-in Navigation panel
     
    magique, dschu, adamstepinski and 3 others like this.