Search Unity

  1. Unity 2019.2 is now released.
    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:
    664
    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

    Unity Technologies

    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:
    664
    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

    Unity Technologies

    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.
     
  5. Griffo

    Griffo

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

    Attached Files:

  6. Jakob_Unity

    Jakob_Unity

    Unity Technologies

    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:
    664
    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:
    664
    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

    Unity Technologies

    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:
    664
    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

    Unity Technologies

    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:
    664
    Yeah, Note to myself .. I really should read the replies more carefully ..