Hi,
For group navigation, instead of sharing the NavMeshPath with SetPath(), I’m considering other solutions without using Unity NavMeshAgent.
For example, some basic flocking behavior where each entity would steer towards the next corner.
Except each entity having different positions (some might even get “pushed” to neighbor polygons not part of the corridor), I’d need to be able to compute the next corner easily.
Would it be possible to have access to the corridor polygons making the NavMeshPath?
As a side note, using NavMeshAgent.SetPath() can fail, but the documentation lacks details about failure cases.
Thanks,
Max
It’s currently not possible to access the navmesh polygons of the path.
Consider to use the NavMeshPath API. For a given path - if you query the corners with 2 vertices you’ll get the first leg of the straight path – see http://docs.unity3d.com/ScriptReference/NavMeshPath.GetCornersNonAlloc.html
One example of SetPath failing: a path on one ‘island’ of navmesh is assigned to an agent positioned on a different (not connected) part of navmesh.
Thanks for the quick reply!
Considering GetCornersNonAlloc, my understanding is that it operates on a calculated NavMeshPath.
But my idea was to avoid making a navmesh path request per entity by sharing NavMeshPath data (ie. the corridor polygons) which would be enough to dynamically recompute the next path corner for each entity using the funnel algorithm without a new request, except maybe when an entity gets off the corridor polygons.
I probably can work out sthg by doing a shorter navmeshpath request from each entity to an intermediate point on the calculated group path to avoid doing a full path request, but I’ll probably have to deal with many small special cases.
I mentioned the SetPath failure cases, because it seems to be more restrictive than being on disconnected part of the navmesh.
It seems to be sthg like if the nav agent can’t get to the first path corner in a straight line (similar to NavMesh.RayCast), SetPath() will fail.
I haven’t investigated much further, but I easily get cases where I try to set a path calculated for the group (from the group barycenter) to all entities within, and some SetPath() will fail even though all parts of the navmesh I’m using are connected.
Example:
- there is a “wall” (non walkable area), it’s possible to go around it
- all entities are on one side of the “wall”
- the group does a NavMeshPath request to go on the other side
- all entities get a successful SetPath() and move around
- midway through, some entities just passed on the other side, the group barycenter is still on the origin side of the wall
- still midway through, the group does a new NavMeshPath request to a destination back on the origin side of the wall
- the entities already on the other side, can get a failed SetPath()
I guess my hope will be that future navigation api changes will include access to more internal data
Thanks again,
Max