Search Unity

Remaining distance returns infinity?

Discussion in 'Navigation' started by appllowastaken, Jan 31, 2019.

  1. appllowastaken

    appllowastaken

    Joined:
    Jan 28, 2019
    Posts:
    5
    I have found that in my code agent.remainingDistance was returning infinity. The docs say this is the case when the agent does not know the remaining distance. I checked agent.pathPending and it returned false. What else could make the remainingDistance infinity, if it knew the path?
     
    Novack likes this.
  2. appllowastaken

    appllowastaken

    Joined:
    Jan 28, 2019
    Posts:
    5
    I found another way to solve my issue, but I still would like to know why it had happened in the first place.
     
  3. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    I read somewhere that remainingDistance is only calculated once the agent has almost completed its path, specifically when the agent has begun traversing the last segment. Before that, remainingDistance will return infinity.
     
    Novack likes this.
  4. appllowastaken

    appllowastaken

    Joined:
    Jan 28, 2019
    Posts:
    5
    Okay. That is what I observed. Then how is that even useful?
     
    Novack and BowlingPin like this.
  5. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Yeah, it's a shame. I assume this is done as an optimization, though I can't say for sure.
     
    Novack likes this.