Search Unity

NavMesh calculate exact time of arrival

Discussion in 'Navigation' started by JDMulti, Sep 26, 2018.

  1. JDMulti

    JDMulti

    Joined:
    Jan 4, 2012
    Posts:
    384
    For a game I'm using NavMesh to let units follow a set of waypoints on a terrain. The thing I want to do is to define the units to walk the total set of waypoints within a certain time limit. The time limit will drive the amount of speed needed to actually arrive on time, so the speed is variable.

    The solution I have for now is that I go trough all waypoints and calculate the total distance. To estimate the total duration of the given path I had them move with a fixed speed for several times and a duration as result. I used that duration to estimate how the speed and travel distance was related to each other. With this factor I could give in a variable duration in seconds and the results were that I'm close to my calculations but quite often 0.5 or 1 second under of over the total duration I want the units to travel the set waypoints. However this calculation is based on a simple linear movement.
    One of the variables I have hard time with is the acceleration and angular speed which result in non linear movement and the reason why my calculation is off for quite a bit.

    My question would be, how can I get NavMesh agents move a set of waypoints within an exact time limit? The way I do it now has it's flaws but maybe there is someone who knows how this could be done. Btw the surface they walk on is completely flat.
     
    Lasko1 and EoinDigit like this.