Hi. I suspect because Unity is super weird with their navmesh stuff it seems like nobody ever made a proper way to notify you in one action in PM to when your agent finished their path.
That's probably because the answer is weird, you do it like this in c# checking two bools for false:
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.NavMeshAgent)]
[Tooltip("Sends an event when an agent has completed their path (once AI bools hasPath and pathPending are false.) \n" +
"NOTE: The Game Object must have a NavMeshAgentcomponent attached.")]
public class AgentArrivedAtDestination : FsmStateAction
{
[RequiredField]
[Tooltip("The Game Object with the Nav Mesh Agent.")]
public UnityEngine.AI.NavMeshAgent agent;
private bool checkHasPath;
private bool checkPathPending;
[Tooltip("Next event when agent is done with their path.")]
public FsmEvent agentArrivedEvent;
[Tooltip("Repeat every frame. For normal purposes this should be ON.")]
public bool everyFrame;
public override void OnEnter()
{
checkPathPending = agent.pathPending;
checkHasPath = agent.hasPath;
if (everyFrame)
{
return;
}
else if (!checkHasPath && !checkPathPending)
{
Fsm.Event(agentArrivedEvent);
}
else
{
Finish();
}
}
public override void OnUpdate()
{
checkPathPending = agent.pathPending;
checkHasPath = agent.hasPath;
if (!checkHasPath && !checkPathPending)
{
Fsm.Event(agentArrivedEvent);
Finish();
}
}
public override void Reset()
{
agent = null;
agentArrivedEvent = null;
everyFrame = false;
}
}
}
Works fine for me using it, but let me know if there's any issue I haven't seen.
edit: cleaned up something that was redundant in code