Multiple AI agents going through the same Nav Mesh Link at the same time ?
Hi there !
I'm facing an issue with AI and NavMeshLinks :
(to know exactly what I'm talking about, there is a video about it in the Brackeys channel : https://youtu.be/blPglabGueM )
So actually, Agents are travelling through those links 1 by 1 and I can't find a way to have multiple agents travelling through the same link at the same time. Even with a large link, only 1 agent at a time seems allowed to go through the link ...
This is actually a big concern for me, because I often need to make groups of agents move quickly from one place to another. But each time there is a NavMeshLink on the road, it creates a huge bottleneck in the navigation flow ...
Any clue ?
To be more precise, in my game the levels are procedurally generated, and I create the links using code. The solution I came up with for now, is to spawn multiple thin links side by side :
But I see 2 issues with this solution :
- It's way more expansive memory wise.
- Actually agents are using an A* algorithm to know the shortest path to the destination, and so if they all decided that the shortest go through THAT particular link, they will just ignore all the other options and all wait in front of the same link, jumping one by one through it and taking a decade to reach the destination :(
Answer by halfpasttense · Aug 31, 2020 at 10:32 PM
I was having this same issue and came up with a solution, but it relies on having to write your own link traversal, something I was doing anyway. The trick is to call NavMeshAgent.Warp to reset the agent's position to its current position as soon as it hits an off mesh link. This has the side effect of disabling the current link traversal on the agent, and it frees up the link for the next agent. Then just move the agent to the end position of the link manually yourself, and call Warp again at the end to update the NavMeshAgent with the new position. It's not a perfect solution since the agents still queue up to use the link, but at least this way each agent only uses the link for a single frame, instead of the whole time it's traversing it.
Your answer
Follow this Question
Related Questions
Problem with NavMesh 0 Answers
NavMeshAgent not teleport on y axis 0 Answers
=> How to Avoid NavMeshAgents Clumping Up Together?! <= 1 Answer
Navigatin Mesh agent works for ~10 seconds, then starts moving sporadically 0 Answers
Have players NavMeshAgent ignore Enemy NavMeshObstacle carving 0 Answers