Search Unity

Bug SetDestition/CalculatePath incorrectly returning a partial path when a long complete path exists

Discussion in 'Navigation' started by skowroshima, Jan 22, 2021.

  1. skowroshima

    skowroshima

    Joined:
    Oct 14, 2018
    Posts:
    75
    I'm having an issue where NavMesh CalculatePath or NavMeshAgent SetDestition incorrectly calculates a partial path when a full path exists.

    In the example below, I was able to add an intermediate destination to give a slightly better starting position, and the it was able to calculate a full path correctly. If I try and calculate a path from the destination to the starting position, it calculates correctly.

    Is there a point where the nav system just gives up and does a partial path? Is there any way around this? Can I take advantage of the fact I can calculate a reverse path?

     
  2. skowroshima

    skowroshima

    Joined:
    Oct 14, 2018
    Posts:
    75
  3. skowroshima

    skowroshima

    Joined:
    Oct 14, 2018
    Posts:
    75
  4. skowroshima

    skowroshima

    Joined:
    Oct 14, 2018
    Posts:
    75
    Does anyone from Unity watch this forum? It would be nice get get an answer in undocumented behavior.
     
  5. skowroshima

    skowroshima

    Joined:
    Oct 14, 2018
    Posts:
    75
    Bump, ran into this again today.
     
  6. skowroshima

    skowroshima

    Joined:
    Oct 14, 2018
    Posts:
    75
    It appears that it may not even be a "max" iterations as I originally thought. The following example calculates a partial path where a full path exists (and isn't that long). I'm guessing it wont try distances longer than some multiple of the "the crow flys" distance?


     
  7. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    300
    I think this is intended, even though it doesn't make any sense. I wrote my own routine to calculate the full path.
    Hope it helps.

    https://pastebin.com/XNdtHxFU
     
  8. skowroshima

    skowroshima

    Joined:
    Oct 14, 2018
    Posts:
    75
    It looks like that will work when the path is too long and it creates a partial path, and you can chain the partial paths together. It doesn't work when the partial path is not a subset of the actual full path. In the picture above the partial path is just a greedy shortest distance to the target, not a subset :(
     
  9. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    300
    Hmm, I see, sorry to hear that.
    Never ran into that issue. If you would make a small sample project I would be happy to look into it.