- Home /
How to queue NavMeshAgents on entering a tile in Unity (based on path distance to tile)?
I'm making a game where multiple NavMeshAgents are trying to navigate to a specific ground tile. All agents should navigate to the edge of this tile, but only the first to reach the edge of the tile should enter it. The agent on the tile will stay there for a set time before leaving it, and will not return to the tile again afterward. Then, this cycle will repeat with the next closest agent entering the tile, and other eligible agents moving as close to the tile without going on top of it.
Note: The player controls obstacles in the game by moving walls, so a path's length can change at any moment if the obstacle layout is modified.
Possible ways that may work that I'm not sure how to implement:
Enabling and disabling invisible barriers
Calling CalculatePath() or SetDestination() repeatedly
Storing and using a List of the NavMeshAgents