playMaker

Author Topic: Get Agent Remaining Distance = Infinity  (Read 1560 times)

Gua

  • Full Member
  • ***
  • Posts: 112
    • View Profile
    • Andrii Vintsevych
Get Agent Remaining Distance = Infinity
« on: September 10, 2014, 07:25:41 AM »
I've tried to set agent destination using "set agent destination" and "Set agent destination as game object" in both cases agent does move to destination, but when I try to calculate remaining distance using "Get Agent Remaining Distance" in both cases the result is infinity. What am I doing wrong?

p.s. Only when there's less than 10 units to the target, it starts to show numbers.
« Last Edit: September 10, 2014, 07:31:51 AM by Gua »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Get Agent Remaining Distance = Infinity
« Reply #1 on: September 11, 2014, 10:44:43 PM »
Hi,

 are you sure the destination AND the agent are on the navmesh?

Bye,

 Jean

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Get Agent Remaining Distance = Infinity
« Reply #2 on: April 30, 2017, 04:41:48 AM »
I am actually running into this same issue. It seems to occur when there is more than two corners for the nav mesh agent to navigate around. My agent and destination are on the same plane. This seems to be unity issue, rather than a playmaker one in specific, but very annoying none-the-less. I am still looking for a solution.

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Get Agent Remaining Distance = Infinity
« Reply #3 on: April 30, 2017, 04:44:18 AM »
I would like to note, once the agent starts getting close to the destination, the calculation does begin, but not until it rounds that first corner.

So this is a unity issue. It has been around since 2015 at least, as reported here: http://unitytipsandtricks.blogspot.com/2015/10/taming-unitys-navigation-system.html

See "Assumption #2", NavMeshAgent.remainingDistance will always tell us how far we have to go.

(Hint, it doesnt always work). They recommend calculating the distance between corners (path points), instead.
« Last Edit: April 30, 2017, 04:48:14 AM by tcmeric »

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Re: Get Agent Remaining Distance = Infinity
« Reply #4 on: April 30, 2017, 09:07:38 AM »
Ive created an action to solve this problem. See here for the info and download: http://hutonggames.com/playmakerforum/index.php?topic=15057.0