playMaker

Author Topic: Calculate Navmesh Agent Path Target Destination by Corners  (Read 544 times)

tcmeric

  • Sr. Member
  • ****
  • Posts: 480
    • View Profile
Calculate Navmesh Agent Path Target Destination by Corners
« on: April 30, 2017, 09:06:51 AM »
Unitys built in NavMeshAgent.remainingDistance can return the result of infinity (instead of the correct distance) when two or more corners (path points) have been calculated. This means the playmaker action "Get Agent Remaining Distance" is not reliable in many cases (as it is using NavMeshAgent.remainingDistance).

An alternative method is calculating the corners (path points) distance instead. An example is given in the unity documentation. I used the documentation to create an action to do so.

https://github.com/dumbgamedev/general-playmaker/blob/master/path/calculateAgentDistanceByCorners.cs

Ive tested it out several times and it returns the same result as the action Get Agent Remaining Distance, except it never returns infinity (good!).

Maybe this action plus the path debug action I posted should be added to the playmaker navmesh package? (Might need name changes/ different category).

autumnboy

  • Playmaker Newbie
  • *
  • Posts: 16
    • View Profile
Re: Calculate Navmesh Agent Path Target Destination by Corners
« Reply #1 on: October 11, 2017, 10:53:48 PM »
Awesome. Get Agent Remaining Distance was driving me crazy. Thanks for this! :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Calculate Navmesh Agent Path Target Destination by Corners
« Reply #2 on: October 12, 2017, 01:04:29 AM »
Hi,

 yes it should be added indeed :)

 Eric, do you feel like adding it to the github rep?

bye,

 Jean