playMaker

Author Topic: Get Agent Remaining Distance Issue  (Read 1915 times)

Athin

  • Full Member
  • ***
  • Posts: 163
Get Agent Remaining Distance Issue
« on: September 23, 2018, 06:58:21 AM »
Hey guys

I've been having this issue when using this action in Playmaker.  I'll set the Agent Destination and under will have the Get Agent Remaining Distance.  Problem is that Remaining Distance always returns 0 firing off my finish pathing event right away. 

I did some research and it looks like it has something to do with the path still calculating when you do the check causing it to think the distance is 0.  I've seen a few people say they fix it but I can't seem to find an action in the ecosystem with the fix and I'm no coder so can't edit it myself.  I've made a simple workaround having a Wait action in there but this isn't ideal.

Is anyone able to help me locate this fix action or guide me to the right spot on how to fix it.

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Get Agent Remaining Distance Issue
« Reply #1 on: September 23, 2018, 01:38:44 PM »
Hi.
Can you give a link to the post that said that he fixed it?

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Get Agent Remaining Distance Issue
« Reply #2 on: September 23, 2018, 11:14:24 PM »
Hi, the easiest solution to this, is to set the distance variable to 10000 in the step before. This should fix the problem.

Also, if the distance is too far from the destination, the default method does not return the correct distance. This is a bug within unity itself. Therefore, I made a second action that calculates the distance properly, called : calculateAgentDistanceByCorners.cs

It can be found here on my github: https://github.com/dumbgamedev/general-playmaker/tree/master/navmesh%20agent

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Get Agent Remaining Distance Issue
« Reply #3 on: September 23, 2018, 11:16:21 PM »
Oh, you can also use the path debug action I made, to make sure the agent can reach the destination.