How to prevent stationary ai agents from being pushed by moving agents?
I have several triggers positioned around the scene which ai agents try to navigate to via Unity's navmesh. Each agent has a collider and kinematic rigidbody attached so that it can interact with the triggers. When an agent reaches the center of the trigger they enter a specific state in which they are stationary for a random period of time.
The problem I am getting is that other non stationary agents can bump into them and push them out of the trigger. And when the agent is pushed out of their trigger they are no longer in position and their stationary state gets cut short. The moving agents have logic which naturally steers them away from stationary agents, but sometimes when there are too many agents in the same spot, or several are moving towards the same target, they can still end up colliding. I would need to make the stationary agents completely immovable by other agents and the player (also a rigidbody and collider setup).
So far I have tried changing the agents radius to almost zero when inside the trigger, but this allows moving agents to pass straight through the stationary agent and in some cases allows multiple stationary agents to stand on top of each other, or rather inside each other. I have also tried enabling a navmesh obstacle around the stationary agent (like a wall around them), to shield them and let the moving agents know that they have to move around this trigger. This works, but it's possible for moving agents to just happen to be in the same position as the navmesh obstacle, and so when the obstacle gets enabled the moving agents will unrealistically snap away from it. This looks quite glitchy. I have also tried to play around with the agent avoidance priority, by increasing it greatly for the stationary agents, but this didn't seem to make much difference.
So my question is how to make the stationary ai agents completely immovable by other agents and the player?
Answer by BaronWhite · May 01, 2018 at 08:22 AM
Don't know how you ended up fixing up, setting the priority of stationary agents to 0 (highest) helps a bit.
There should be a way to "root" the agents as if they were obstacles. And the workaround for this is having a navmesh collider component which you would enable whenever they are stationary.
Is it possible though for a multiplayer game to play with priorities in a way to make sure that you can only push your own units and can not push enemies and the opposite for your real-time opponent so he can only push his own units but not $$anonymous$$e?