Search Unity

Navmesh agents to avoid other agents

Discussion in 'Navigation' started by skinwalker, Oct 16, 2017.

  1. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510


    Its because baking a navmesh uses a lot of resources, that's why its done offline. Its completely different than using a NavMeshObstacle.

    By the way, you don't need to use carve to have it not go through another agent. Carve actually puts a whole in the Navmesh, less performant prevents other agents from calculating a path through it, which would be a problem in something like a doorway. Using it without carve prevents the agent from moving through it, but also allows it to calulate a path.

    It really depends on your use case, but just letting you know that you don't have to use carve.
     
  2. Mortalanimal

    Mortalanimal

    Joined:
    Jun 7, 2014
    Posts:
    567

    Problem I have, is that I do need it to calculate a new path, because if I have several obstacles "without carve", the units trying to get past will just get stuck. whereas if they had "carve on", they will use a new path and thus they wont get stuck.

    Now the thing is, obstacle avoidance works exactly the same as having the other Unit that you want to avoid with Higher priority which is more convenient (correct me if I am wrong). The biggest problem is, both these features are not good enough and they look quite unnatural, thats why I wanted to just increase the cost in the area that I want to be avoided, but under high stress that area will still be usable (basically what ever ends up costing less).

    Now, I know one extremely costly way to do this, and that is to divide the map into a grid (small squares), and each division/square having there own tiny navMesh, then I can just change the cost of the navmesh that I am standing on. but in my experience, that will be extremely costly. I may as well make my own A* Pathfinding, which is ofc something I am trying to avoid.

    I had some help on how to change the nav mesh cost, But It was way too advanced for me, and If I am being honest, I didnt understand any part of the code. even though i understood 90% of the explanation.

    https://forum.unity.com/threads/how-to-create-a-dynamic-area-cast-in-navmesh.792459/#post-5276964
     
  3. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    After I looked at the documentation and test it myself, I've noticed that avoidance priority only allows an agent to ignore other agents or not.

    Lower Priority
    1. If an agent of the same or lower priority is trying to get past a group of agents, it will slow down and stay behind the others.
    2. If its near the left or right of the group, it will go around.

    Higher Priority
    2. If an agent of higher priority is trying to get past a group of agents, it will just go through them and push them out the way.

    So for them to go around, there would need to some other method.

    That sounds way to rigid, too much work and most likely not performant.

    Btw, I actually dynamically change the cost of navmesh areas in my game, however, its not done every frame to direct agents around each other.
     
  4. Mortalanimal

    Mortalanimal

    Joined:
    Jun 7, 2014
    Posts:
    567
    @FiveFingerStudios,

    Thanks for reply

    That would actually be good enough for me, even if its once every second that would still be good enough for what I am trying to achieve.


    Thats something I dont mind, however, what I want is for units with the same priority, or lower priority to walk around units of the same priority or higher priority. This works, however, if you have a wall of units, they would not walk around the wall of units. because its not using the path finding system to avoid those units in the first place, its using RVO. Thats why i need the cost system, I want to reroute before I even need to use RVO.
     
    Last edited: Dec 15, 2019
  5. jadvrodrigues

    jadvrodrigues

    Joined:
    Feb 25, 2020
    Posts:
    12
  6. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    Dude the comment you replied to, I made 4 years ago. The discussion moved on and I have not kept up with this thread, I recommend replying to comments made within the last year next time if you want a decent response
     
  7. trullilulli

    trullilulli

    Joined:
    Sep 4, 2013
    Posts:
    7
  8. IneptStudio

    IneptStudio

    Joined:
    Mar 7, 2022
    Posts:
    12
    Nav Mesh Agent> Obstacle Avoidance > Quality > None.

    It removes the collision between all the Nav mesh agent against each other. And follow the path as it is . I think this should work.
     
  9. macsimilian

    macsimilian

    Joined:
    Sep 19, 2020
    Posts:
    25
    What if you have a moving destination? Then can't just calculate the path once and turn off NavMeshAgent