playMaker

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

Gua

  • Beta Group
  • Sr. Member
  • *
  • Posts: 309
    • Andrii Vintsevych
Get Agent Remaining Distance = Infinity
« on: September 10, 2014, 10: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, 10:31:51 AM by Gua »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Agent Remaining Distance = Infinity
« Reply #1 on: September 12, 2014, 01:44:43 AM »
Hi,

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

Bye,

 Jean

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Get Agent Remaining Distance = Infinity
« Reply #2 on: April 30, 2017, 07: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

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Get Agent Remaining Distance = Infinity
« Reply #3 on: April 30, 2017, 07: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, 07:48:14 AM by tcmeric »

tcmeric

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