Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

NavMesh link does not connect properly in runtime

Discussion in 'Navigation' started by F_J, May 29, 2017.

  1. F_J

    F_J

    Joined:
    Apr 29, 2016
    Posts:
    9
    I am using the latest version of Unity 2017.1f1 currently up-to-date.

    What I am trying to do

    In my 2.5D game, I am spawning enemies that will navigate towards the player while avoiding obstacles (with curving enabled) spawned in runtime. I also spawn a plane (on which the player and enemies moves) additively, I want the current plane navMesh surface to connect to the next spawned plane navMesh surface with a navMesh link so that the enemies can navigate to other planes via the link.

    What is the Problem?

    The link closer to the obstacle whose curving is enabled do not get connected to the next plane.

    My Implementation

    First of all, I am using the navMesh components provided by Unity on GitHub to achieve this in runtime. Now when I spawn the plane additively I first build the navMesh surface then update its attached links.

    Code (CSharp):
    1. nextPlaneSurface.BuildNavMesh();
    2. for (int i = 0; i < nextPlaneLinks.Length; i++) {
    3.     nextPlaneLinks[i].UpdateLink();
    4. }
    Next, I update the current plane (which the player is on) navMesh links to connect with the newly spawned plane navMesh surface.

    Code (CSharp):
    1. for (int i = 0; i < currPlaneLinks.Length; i++) {
    2.     currPlaneLinks[i].UpdateLink();
    3. }
    What I have done to try to fix the problem
    • Updating the current links and rebuilding the navMesh before and after spawning the obstacles.
    • Updating only the current links before and after spawning the obstacles.

    Will really appreciate it if anyone can help me out, also if you guys can explain what's happening internally in the unity scripts that will be really helpful. After all, I am having these problems because I don't understand the concept properly.
     
    Last edited: Dec 16, 2020
  2. nesta219

    nesta219

    Joined:
    Nov 3, 2015
    Posts:
    14
    I am having trouble with this as well... I have positioned the nav links in what seems to be the right position, but they still won't activate... anyone out there?
     
  3. F_J

    F_J

    Joined:
    Apr 29, 2016
    Posts:
    9
    Seriously, I still can't find any solution for the problem, can anyone help us?
     
  4. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    First off, that github repository is out of date and no longer used.

    So taking that out would be first point of call. Secondly, most of the github has been added into the main unity release. Try looking at navmeshbuilder,
     
  5. F_J

    F_J

    Joined:
    Apr 29, 2016
    Posts:
    9
    Daemonhahn, I doubt that it's out of date, most of the recent tutorials* on runtime navmesh generation uses components from the Github repository.

    I am able to link the two planes on runtime without spawning the obstacles but with the obstacles on the plane, the link seems to break.

    *was uploaded on Aug 2017, which is quite recent. Plus, he is using the navmesh surface component from the Github repository, he mentions this at 2:10 in the video.
     
  6. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    If you check changelogs etc, a lot of the behaviour has become navmeshbuilder, whilst some is not available at the moment.

    Instead of ignoring what i said, look at https://docs.unity3d.com/ScriptReference/AI.NavMeshBuilder.html like i suggested first? You will likely find you can do a lot of what you need with it.

    Also august is NOT recent. If you are using unity 2017.x then you need to not be using a github repo that is 3 months old with it, otherwise ofcourse there will be bugs. That repo is where research on that system is done, when it is finished it is moved to the main release like i explained earlier. Sorry if I didnt make it clear enough last time.

    EDIT: and as a unity user of many years I can tell you, assuming the tutorials or even the documentation is up to date and using recent, best trends is a bad habit, as they are usually out of date by the time their out.

    EDIT2: https://forum.unity.com/threads/integration-of-navmesh-building-components.489727/ and https://forum.unity.com/threads/sol...can-only-be-called-error.469686/#post-3229808 this is a link to a thread that is already on this, which I and many others have already answered this question in. As you will see, the overall advice is to remove it as its not finished, which I had said before.
     
  7. F_J

    F_J

    Joined:
    Apr 29, 2016
    Posts:
    9
    I looked into the navmesh surface component script and it is using the navmesh builder API internally. I can't just use the navmesh builder directly, I need the navmesh surface because it bakes on any axis the plane is facing, you cannot do that with static navmesh it only works on Y axis :(. Is there a workaround for this?

    P.S sorry for the late reply, I was on vacation :p

    BTW thanks for the advice.
     
  8. F_J

    F_J

    Joined:
    Apr 29, 2016
    Posts:
    9
    I finally found the solution to my problem, the reason why I wasn't able to link the two planes was that the Navmesh surface tile size was too large. After reducing the tile size the link was connecting with the obstacles on the planes.

    For a beginner, you can find tile size field under NavMeshSurface component (provided by Unity on GitHub) in advance section.