How to get notified when a waypoint reached?

Hi All,

We just found AIPath.OnTargetReached () for final destination. We were looking for a similar method to override for reaching each point in vectorPath. We are only allowing one path calculation until you reach the next destination to save performance on mobile. This broke our solution that checked vectorPath each OnPathComplete() was called.



In the AIPath script there is a currentWaypointIndex field, that will increase each time the waypoint changes. There is no method for it currently.

This solution only works if you prevent path calculation until you reach the destination. We have too many NPC and have to prevent repeated SearchPath.

If you repeatedly call SearchPath canSearch = true, the index is always 1 and never increases.
So the definition of waypoint changes? There is NO such thing as a waypoint if old path thrown away and new one created every repeatRate.

Where to get a hook into code for reaching a GraphNode? We are using a PointGraph for our Hex grid domain model.


Ok, then you can check which node is the closest and check when that changes.

var closestNode = (myPosition, NNConstraint.None);
if (closestNode != previousClosestNode) {
   // Reached new node
   previousClosestNode = closestNode;

Or something like that.

Thanks for the insight!

The reasoning is the hex model is decoupled from the astar space.
So moving in the astar space needs to be updated in the hex board space.
Unless this is a bad design approach.

Ok, but I assume you have some way of converting between the spaces? (since you do follow a path generated by the pathfinding system).

You can also just check the first node in the path request that you get back since that will be the node that the agent started on.