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

[SOLVED] NavMesh and stairs Unity 5.0.1f1

Discussion in 'Navigation' started by Griffo, May 28, 2015.

  1. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Hi, why can I never get the NavMesh to go up stair easily ?

    I noticed in the latest Unity 5 release they have changed the advanced NavMesh settings ...

    Can someone please tell me what I'm doing wrong, and how to get the NavMesh up the stairs.
     

    Attached Files:

  2. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Maybe i'm missing something in the picture - but isn't the navmesh going up the stairs - or is it disconnected at some point ? It's hard to tell when not being able to rotate the view. Notice that the navmesh (being an approximation) some-times dips under the render geometry on which it's based.
     
  3. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Hi, The NavMesh is broken at the very bottom of the lower steps then a third of the way up.

    Then on the upper steps it's broken at the bottom, middle and top.

    I've tried multiple setting with mostly breaks in the NavMesh, the only fool proof solution I've found is to make a squashed down cube and turn it's renderer off and us it as a ramp up the steps, but I shouldn't need to be doing this.
     

    Attached Files:

  4. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    ok thx for pointing it out - again it's a bit hard to guage from an image. However - "Step Height" seems a bit low to me - if a step is slightly higher than 0.2 units it will get disconnected. Try Step Height 0.4 and let me know if it still fails.
     
    SDC2X likes this.
  5. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    OK, tried that and also up to 0.6 and still many breaks ..
     

    Attached Files:

  6. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    On the latest screenshots it looks to me like the navmesh debug geometry just dips under the render geom. - could you annotate the gaps as before or temporarily disable the rendergeometry for the stairs ?
     
  7. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    OK, tried another way, used the collider object to generate the NavMesh, as that is a ramp, but still have breaks at the top of each ramp !!
     

    Attached Files:

  8. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Why did you change the Advanced options ? As before when I had this problem I found adjusting the height inaccuracy fixed the problem !!

    Thats why I have this screen grab as reference when I came across this problem.
     

    Attached Files:

    Last edited: May 30, 2015
  9. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Still - to me it looks like it's connected - are you sure it's broken ? Try to move the geometry down (y-axis) after baking navmesh and have another look at the navmesh, or - alternatively - calculate a path from bottom to top of stairs - drawing the path found, you can use the script below for that. It calculates a path between the GO it's attached to and the 'target' GO assigned to it. Then draws a green line for the resulting path - above the navmesh

    Code (csharp):
    1. //CalculatePathTest.cs
    2. using UnityEngine;
    3. [ExecuteInEditMode]
    4. public class CalculatePathTest : MonoBehaviour {
    5.    public Transform target;
    6.    void OnDrawGizmos () {
    7.      if (target == null) return;
    8.  
    9.      var path = new NavMeshPath();
    10.      NavMesh.CalculatePath (transform.position, target.position, NavMesh.AllAreas, path);
    11.  
    12.      Gizmos.color = Color.red;
    13.      Gizmos.DrawRay (transform.position, Vector3.up);
    14.      Gizmos.DrawRay (target.transform.position, Vector3.up);
    15.      Gizmos.color = Color.green;
    16.      var offset = 0.2f * Vector3.up;
    17.      for (int i = 1; i < path.corners.Length; ++i)
    18.        Gizmos.DrawLine (path.corners[i-1] + offset, path.corners[i] + offset);
    19.    }
    20. }
    21.  
     
  10. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Jakob_Unity you are correct, after lowering the steps the NavMesh shows in full.

    I don't believe I missed a simple thing like that, I was to fixed on how it looked rather than testing it, if I'd put a NavMesh Agent on there to chase me (as I just did) he would have run up the steps (as he just did:)) with out any problems ..

    Thank you for your input, much appreciated, so am I right in saying it's only cosmetic, it won't stop any NavMesh Agents going up or down step with the NavMesh looking broke?
     

    Attached Files:

  11. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    you're welcome - I think you might very well get disconnected navmesh if the step height is around 0.2 (assuming metric units - that's close to the typical step height) - better go with 0.4.

    but yeah - quoting myself :
    > Notice that the navmesh (being an approximation) some-times dips under the render geometry on which it's based.
     
  12. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    700
    Yeah, Note to myself .. I really should read the replies more carefully ..
     
  13. SDC2X

    SDC2X

    Joined:
    Apr 4, 2017
    Posts:
    8
    Jakob, your solutions is what i have selected and work! Thank you for this solutions!

    Unity need one solutions for NavMesh Editor Integrated!

    Is stupid i cannot edit navmesh !

    Need this "Nav Mesh Editor in the Unity editor , can help any member !" """ Requested!"""
    can solve many problem, "like stairs" and many other!"

    " NAV MESH EDITOR !" NEED ONE VERSION , OR ANY OTHER BUT MUST WORK!


    Unity NEED ONE REAL NAV MESH EDITOR INTEGRATED!! with love need it!
     
    Last edited: Jun 20, 2022
  14. pramartaej

    pramartaej

    Joined:
    Aug 8, 2021
    Posts:
    1
    If you look the staircase, you see, its like a line 45 degrees or staircase but its the nav mesh agent it's like cutting the navmesh agent. So the answer is working :)! Look the image's, you can see the first image is looking at the top, and also the second image is looking at the bottom.. As you can see, the first image is looking weird because the navmesh agent, making staircase is like cutting the navmesh agent, so the second is the navmesh agent is not like a error :D!
    You don't need a code, just a edit "Bake", then click "Bake" button, then wait until bake is complete, then done! :cool:

    The First Image:


    The Second Image:


    Try it! :)