I am using the following code (that I wrote for playmaker), to path a random destination point within a range. I am using the seeker component and AI Path component on a game object for movement.
Often the agent gets stuck before reaching the destination. It seems like maybe the final destination point is in an unwalkable zone? Can you check my random path script to see if I am making an error somewhere? (this code was based on an example posted here).
(variable.Value, just means playmaker can access the variable
go = the current game object
var rndPoint = go.transform.position + Random.insideUnitSphere * Random.Range(MinWanderArea.Value, MaxWanderArea.Value); var closestPointOnNavmesh = AstarPath.active.GetNearest(rndPoint).clampedPosition; randomDestination.Value = closestPointOnNavmesh; seeker.StartPath(go.transform.position, closestPointOnNavmesh, OnPathComplete);
If you can see in my images, the AI agent stops about 2 floats away from its final destination. It seems to be pathed into some obstacles.