Forum rules - please read before posting.

Question about 2D navmesh holes

I made a 2D navmesh with a door and used a hole to block it, the player avoids the hole but only to the edge of the navmesh, then walks through the hole. Is this the expected behavior?

Unity 2018.2.19f1
AC 1.65.2

Comments

  • Please share screenshots to illustrate what you mean - it's a visual problem, and there's not enough detail here to understand what's going on.

  • edited December 2018

    https://ibb.co/z8v61L4

    Is that clear?
    I'm also experiencing another issue where if I delete the hole on the navmesh, I get the Unity error:

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[UnityEngine.PolygonCollider2D].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    AC.NavigationEngine_PolygonCollider.NavigationMeshGUI (AC.NavigationMesh _target) (at Assets/AdventureCreator/Scripts/Navigation/NavigationEngine_PolygonCollider.cs:827)
    AC.NavigationMeshEditor.OnInspectorGUI () (at Assets/AdventureCreator/Scripts/Navigation/Editor/NavigationMeshEditor.cs:20)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1375)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

    and the Navmesh hole will return to the object when you reselect the navmesh.

  • A fix for the issue when removing holes will be included in the upcoming v1.66 update.

    A NavMesh hole cannot overlap the NavMesh like that - it needs to be contained within the boundary. If a hole does go over the edge (and only one side), it'll act as a continuation of the NavMesh.

    Therefore, there are two options to create a dynamic walkable area:

    1. Have your NavMesh cover only the portion of the scene that the Player can move when the gate is shut, and have the NavMesh hold cover the extra area when the gate is open (but also slightly overlapping the top portion of the NavMesh). Add this hole at runtime using the Scene: Change setting Action when the gate opens.

    2. Reshape your NavMesh as with 1., but then create a second NavMesh that covers the whole area of the scene that the Player can move when the gate is open (i.e. including that covered by the first NavMesh). Have this second NavMesh replaced the first at runtime using the Scene: Change setting Action when the gate opens.

  • Thanks again for your help, Chris. I went with the second option.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.