Search Unity

Problem using NavMesh.SamplePosition

Discussion in 'Navigation' started by Shadowing, Mar 8, 2019.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Having issues using SamplePosition. Its not returning a spot on the nav mesh. Returns the same spot my RandomPosition is set too.

    I guess its cause im using NavMesh.AllAreas. I just want walkable areas.
    If I set it to 1 << 0. SamplePosition returns false.


    Code (csharp):
    1.  
    2.              RandomPosition = new Vector3(-19.38f, 128, -93.07f); // Override Test
    3.          
    4.  
    5.             if(NavMesh.SamplePosition(RandomPosition, out NavMeshHit myNavHit, 100 , NavMesh.AllAreas)){
    6.                 Debug.Log(myNavHit.position);
    7.                 TargetPosition = myNavHit.position;
    8.             }
    9.  
    This is a picture showing that I set the RandomPosition to be inside this building where Navmesh does not go.

     
    Last edited: Mar 8, 2019
  2. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Bump. Really stumped here
     
  3. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    My next step i guess is to make a separate project and send it in as a bug.
    Wondering if someone could at least maybe back me up in thinking this looks like a bug.
    Using Unity 2018.3.6
     
  4. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648