Forum rules - please read before posting.

Player and NPCs not respecting navmesh

Hi Chris,

I've come across a bug that I can't seem to fix. Sometimes the player and NPC followers will walk straight through a navmesh hole (the same thing happens when a single navmesh has a similar shape as this, so I don't think it's a bug with the holes specifically). Here's an example:


I made a video showing the bug (it happens several times, but it also works correctly several times, so I'm not sure what's going on):

Do you know what could be causing this? Any help would be greatly appreciated.


  • AC and Unity version numbers, please.

    What does the problematic portion of the NavMesh in the video look like?  Let's also see the Inspector of your Navigation Mesh, and the Settings Manager's Movement settings.

    Does the same issue occur if you assign the 2DDemo_SettingsManager and have the 2D Demo player prefab, Brain2D, walking around instead?
  • Unity version is 2017.1.0p4
    AC version is 1.60.5

    Here's Brain2D using  2DDemo_SettingsManager, ignoring the navmesh hole:


    He never walks into the hole if I click on the hole itself. He only enters the hole if I click on the walkable part of the navmesh above (or above it). Even then, he goes around the hole correctly maybe 80% of the time. Also, I find it easier to reproduce the bug if I click on the upper part of the navmesh when Brain2D is immediately below it - when he's near the left corner of the screen and has to walk along the lower part of the navmesh first, he rarely decides to cut corners. NPC followers display the same bug, but more often.

    Here are the movement settings:


    The bug still happens when destination accuracy is 1 and "attempt to be super-accurate is checked.

    And here's the navmesh inspector:


    I was using lower accuracy because the game stutters a lot otherwise, and the stutters actually seem to cause this type of bug more often - the characters often find themselves out of the navmesh after a stutter, and then they slowly walk back into it. Anyway, even with accuracy 1, I can still reproduce the bug.
  • I'm not clear where the hole lies, or why a hole is necessary in this case.  The shape in your screenshot could be made with a single NavMesh.

    PM me the scene file, I'll need to see it for myself.
  • Hey Chris, the hole was necessary because the whole NavMesh is shaped like this:

    Black is the NavMesh, blue is Hole 1, red is Hole 2.

    Anyway, I investigated the issue a bit further, and I think I understand the problem now. I followed your advice and created a single NavMesh in the shape of the problematic area without any holes. It turns out the problem isn't the hole at all.

    What is happening here is that, for one reason or another, the player and NPCs are finding themselves slightly outside the NavMesh. I had seen this happen quite often before in other scenarios, but then they would walk back in as they kept moving, and they were outside it by so little that it didn't matter. The problem in this particular scenario is that once Brain2D is slightly outside the navmesh, if you click on a different area of the Navmesh above it, he won't navigate from where he is - he will walk straight to the destination point until he finds himself inside the NavMesh again. Does this make sense?

    Here is a video of a new scene with the same bug:

    And here is a package for you to import into a project with AC:
  • I'm afraid I can't reproduce the issue exactly, as the player remains on the NavMesh at all times.

    However, if I manually move Brain just off it, then he walks across the gap as you show in the video.

    First of all, update to the latest release, and check "Retro-movement" in the character components - that's a new movement geared towards more classic movement seen in older games, and may be appropriate given your art style.

    Secondly, break your long thin NavMesh sections by adding vertices along it (the top angular slope should have e.g. 3 pairs along it).  This is similar to the practice of avoiding long, thin faces when modelling in 3D.  After adding a few verts along the long sections, Brain obeyed the NavMesh even when pushed slightly off.
  • Thanks for looking into it, Chris. Sadly it didn't make a difference here. :/ What I ended up doing was to line the problematic spot with a CollisionCube2D to ensure the characters won't walk through it. It's a bit hacky but it works.
  • Too hacky for my liking.  If you can create a new project that has just core AC, your scene, and Managers, please zip it up and PM it to me in private - I'd like to reproduce this.
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.
Do NOT follow this link or you will be banned from the site!