Performance implication for multiple agents and pathfinding setup

Hi,

I have a pretty general question about the library. I used the pathfinding library for the past months for single AI characters/agents (the movement script and AI scripts are self-written and integrated into my own BT). Now I like to extend some ideas which made me rework some of my existing AI integration where I now face some challenges.

Setup:
I have a 2D platformer where there are multiple agents in the same scene. Each agent is able to navigate a maze-like structure with their own individual goals. There are (dynamic) obstacles in the scene that the agent should not use for navigation (e.g. this could be a specific object that the AI is not intended to pick up or the player which the AI should not collide with). Currently, all the agents use the same grid graph for navigation (as of now, they all have the same size which will only be different in exceptional cases).

Change in setup
After the rework, I have different agents that should fulfill different tasks/behave differently (realized using a self-written BT) and also have different strengths. Strength is important as once agents/objects collide, only the “stronger” survives (strength is defined on an infinite scale from 1 → Infinite). I also have some objects which should not be picked up by AI (only the player) and therefore should be treated as regular obstacles by navigation (I can achieve this with TAGS). I also have other objects that should only be treated as obstacles in different situations (e.g. as long as a certain strength is not reached => In theory can also be done with TAGS ?).

Questions
As I now have multiple agents all with different strange tasks all navigating the same grid, I’m not sure about the best setup and see the following questions in regard to navigation:

  1. I did not find a way to use TAGS in the given setup because the tag will apply to all agents using the same grid. Is there a way for multiple agents to share the same grid but consider different obstacles differently which also can change over time as some agents get stronger and so an object that was not traversable before, becomes traversable later (but only for that single agent)? I also think using my own AI and evading all the obstacles might not be a good idea as there might be 100th of such obstacles in the scene.
  2. I was thinking about using different grids for each agent, there I could use the ITraversableProvider to exclude certain objects => disadvantage would be that I need to scan the graph again whenever an object is removed and also, I would not be able to use Unity Physics to find the objects but some sort of thread-save list to store a reference to all my objects and entities that impact the navigation. I’m not sure if this is a good idea to do due to resource limitations => I intend to ship to mobile devices as well. Is having multiple grids (I assume up to 50) even a good idea or should they be shared when possible?

I’m a bit lost here on what might be the best approach to resolve this problem. It would be best if I would be able to define a dynamic condition/or TAG (based on attributes from the agent as well as the obstacle) that only impacts the navigation of that specific agent. Is there a way to achieve such a thing? I assume I’m not the only one having such problems.

Any help would be highly welcome.

Hi

This sounds like a complex setup, but it seems doable.
You can use multiple graphs to handle agents with different sizes (see Multiple agent types - A* Pathfinding Project).
You can use tags for the obstacles that should only sometime be treated as obstacles.

Yes. The Seeker component has all the settings for how a tag is treated. Since these settings are per seeker, you can change them independently for each agent and also change them over time.

I would not recommend that many grids (though it is possible in theory). I’d recommend trying to keep the number of grids to a smallish number, like 2-4 (depends on how big your world is).