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

Discussion Determining length of a path

Discussion in 'Navigation' started by JacobDecisionLab, Feb 8, 2023.

  1. JacobDecisionLab

    JacobDecisionLab

    Joined:
    Nov 16, 2022
    Posts:
    9
    Hi. For the project I am currently working on I need my AI agent to be to make a decent estimate of how long a journey from it's current location to another location will take, without actually setting it's destination, for decision making purposes. I know that using SetDestination and then remaining distance is probably the most accurate result, but this requires me to actually set the destination and it could take multiple frames to determine the path

    I have looked at other suggestions by using CalculatePath and then working out the vector distances between each of the corners of the path. This gives a decent estimate, however the navmesh I am using is very large and the calculated path and the actual path traversed are different (e.g the current path I am testing is 575 when using calculate path but only 521 when I set the destination and use remaining distance)

    Is there any other known method for calculating the distance or will I have to settle for using calculate path and accepting that my estimations will have some errors?