- Home /
Filtering NavMesh Agent Forces
In my current scene I have a group of NavMesh agents which are spawned into the world and told to chase a player.
In order to have the agents collide soundly with the player I had to add a NavMesh agent to the player object. So this player object now has a CharacterController which is used for movement, and a NavMesh agent which i have set not to calculate a path.
The only issue now is that each agent is now able to push against each other, and the player. so if the agents do catch up to the player they just push it around as a large group.
Is there a way that i can filter the forces on the player so that being pushed by another agent does not make it move backwards, or to filter forces from enemy agents from the player.
Ideally i would like the enemy agents to not push the player around, and the player to not push the enemy so there is a danger of being swarmed.
I would also like to know how to do this and stop the big shoving-fest I get when lots of people go to the same area. A weight parameter we can set in each agent would be perfect so some people can push others out of the way.
Has this been resolved? I'm using a Nav$$anonymous$$eshAgent to control a giant rhino, and an agent on my player controller to ensure collisions with said rhino. But now my player can push the rhino around which looks completely unrealistic!
No it hasn't been resolved, and is old enough now that it probably won't be.
On the particular project I was having this issue the level got redesigned (it became much simpler), and i was able to not use navmesh for navigation.
Have you tried Nav$$anonymous$$eshAgent.avoidancePriority?
This feature was added to Nav$$anonymous$$eshAgent I guess as a hack to fix these sorts of issues. You can set the priorities so e.g. the Rhino can push all other agents but cant be pushed back.
Thanks so much RefugeZero, that does work! I thought I had tried playing with that value, but it wasn't super obvious how to use it (or that it would have this effect)... Thanks again!
Answer by jglazman · Jun 19, 2012 at 07:12 PM
This seems to me like a bug with Unity's RVO implementation.
If you have one NavMeshAgent with a slow velocity a handful of other agents with a higher velocity, then you tell them all to go to the same place, if the slow agent is in front of the faster agents it will get pushed along and far exceed its defined velocity. This should not happen.
Your answer
Follow this Question
Related Questions
Problems with pushing rigidbodies while standing on them 3 Answers
Stop or cancel movement if the player hits wall. 2 Answers
Pushed objects randomly sliding into walls 0 Answers
Arrows not stopping immediately when target hit? 3 Answers
NavMeshAgent Not Registering Correct Collision with Static Objects 0 Answers