I am using a NavMeshAgent and wanted to do a calculation based on the next waypoint on its path. I looked at the doc for NavMeshAgent and found nextPosition and read its doc which says:
The next position on the path. – A path consists of waypoints that are aimed for in succession by the agent as it navigates. This property contains the position of the waypoint the agent is currently heading for. When this point is reached, the target will be advanced to the next waypoint, and so on until the agent lands at the destination point.
Somewhat later I found steeringTarget whose doc says:
The current steering target - usually the next corner or end point of the current path. (Read Only)
It turns out that steeringTarget is the value I want. But on the way to figuring that out, I was pretty confused by the behavior of nextPosition. As near as I can tell, nextPosition is exactly the same value as position. That is, as my agent advances along the navmesh path, this expression returns zero on every frame:
Vector3.Distance (navMeshAgent.transform.position, navMeshAgent.nextPosition)
Is that the way it is supposed to work? And if so, isn’t the documentation for nextPosition wrong?
Thanks for any enlightenment,
Craig Reynolds