Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

AI Local Avoidance 3.0.0

Discussion in 'Tools In Progress' started by Lukas_Ch, Jun 23, 2022.

  1. boyaregames

    boyaregames

    Joined:
    Jun 23, 2021
    Posts:
    58
    Hello, thx for your great work!
    I have a question.
    How to draw a path to destination?
    I mean how can i get "node" positions to draw my path from A to B accordind to nav mesh result
     
  2. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    I assume you ask about agents navigation. In Mono selecting agent, should draw nodes that it will traverse.
     
    boyaregames likes this.
  3. yfowc

    yfowc

    Joined:
    Nov 29, 2018
    Posts:
    2
    I don't need physics. Can I use AgentCollider instead of Unity's Collider?
     
  4. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    715
    I'm pretty sure that you can. It will keep the agents from overlapping and have superior performance.
     
  5. LeeJiHoon

    LeeJiHoon

    Joined:
    Aug 4, 2016
    Posts:
    12
    It's so weird when a big monster avoids a small monster.

    It seems that I saw in the post that there is a work plan related to this.

    i'm waiting for this
     
  6. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
    Hi. I have purchased it, but I was wondering what can we do about situations such as having non spherical collision such as boat or ship... What do you think the best approach be? If you make the size of agent to cover the length of the ship, it just makes the width area so much empty and wasted space?
     
  7. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    715
    I'm assuming you were the one who asked this question in the discord this morning. For anyone reading this, the answer that Lukas gave is that accounting for different shapes would slow down local avoidance so much that it wouldn't be worth it.

    I will also add that one solution you could try is using physics colliders instead of the local avoidance algorithm. It will use more CPU so your max agent count will be about 1/2 and it will also come with a lot of benefits or issues (depending on how you look at it) such as gravity effects, bounce, rotation, etc. Unity physics also is known for running pretty poorly mobile platforms. There is a benchmarking utility here: https://gitlab.com/lclemens/PdBenchmark which has an option for unity physics so you can test performance and behavior between the two.
     
    Lukas_Ch likes this.
  8. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    97
    hey small question, any chance the 2021.3.x iteration of unity will ever be supported?
    changing to 2022.3 sorta breaks the current projects sadly
     
  9. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    Sadly, this requirements comes from ECS as minimum supported version is 2022
     
  10. creativelefty

    creativelefty

    Joined:
    Jan 28, 2017
    Posts:
    8
    Can I use this asset for 2D navigation without the need for navmesh and navmesh surfaces (ie; to find paths around 2D colliders without I assume a navmesh) if I'm coding in unity DOTS (in unity 2022)? And, if so will it be faster than calculating a path compared to using navmesh surface calculations?
     
  11. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    Yes, most of the components in the package are optional. You can omit the navmesh by simply not adding the navmesh component to agent. However, I assume you will would want some kind of pathing in ure 2d game or u plan to solely relay on obstacle avoidance?
     
  12. creativelefty

    creativelefty

    Joined:
    Jan 28, 2017
    Posts:
    8
    I'm more interested in 2D pathfinding, local avoidance not so much (which is the main reason I got the Agent Navigation asset over your Local Avoidance asset). So Agent Navigation can't do path finding on its own without navmesh APIs (currently I use navMeshPlus)? I have 100s of 2D static colliders in the scene (basically walls of houses, some joined together some not) as well as 100s of units that use pathfinding. Just wasn't sure navmeshplus would be efficient in DOTS, hence another reason I grabbed Agent Navigation.
     
  13. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    I think navmeshplus only affects baking part, so it should not impact pathfinding part. Agents navigation uses unity navmesh surfaces (You can use navmeshplus, for baking 2d navmesh surfaces) and for pathfinding it runs via dots compatible APIs.
     
  14. Panek

    Panek

    Joined:
    Jul 12, 2012
    Posts:
    5
    I have a problem when it comes to performance as I use the asset in subscenes.

    I'm testing on a scene where I have 800 agents and if I use hybrid approach I have a constant 72 fps ( testing on oculust quest 2 so maybe it's something related to android). If I use subscenes then I have between 40-70 fps.

    Maybe I am setting something wrong ? Also as far as I can see there are no sample scenes what use subscenes so I can compare if I am doing something wrong.

    Unity 2022.3.10f.
     
  15. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    I assume you use ecs graphics for rendering, my first suspect would be to check via profiler maybe ecs graphics runs slow on oculus.
     
  16. Panek

    Panek

    Joined:
    Jul 12, 2012
    Posts:
    5
    It's not likely to be that. I use regular cubes for test.
    Is there a chance that in future versions there will be some example using pure ecs ?
     
  17. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    The mesh itself should not matter, as I assume you are having cpu cost issue. Maybe you can send me profiler sample, I could take a look.
    For pure ECS samples, the reason they are not there as it would require to have ecs graphics and that would be introduce huge cost on users that do not sure pure ECS (Entities graphics adds lots of shader variants by just existing in package). As example zerg sample is basically pure ECS, just does not use subscenes and uses mono to render/animate
     
  18. LeeJiHoon

    LeeJiHoon

    Joined:
    Aug 4, 2016
    Posts:
    12
    I'm making a mobile game, so performance is more important than quality.
    So I used Agent Separation, but the quality of Avoid was not good.

    So I try to enable AgentSonarAvoid only for enemies close to the player.
    Does frequent enabling/disabling of AgentSonarAvoid have any performance issues?

    Do you have any other options or ideas to improve performance?
     
    Last edited: Oct 8, 2023
  19. unitygnoob008

    unitygnoob008

    Joined:
    Sep 17, 2016
    Posts:
    229
    hi
    how do we go about making your asset work using https://assetstore.unity.com/packages/tools/behavior-ai/a-pathfinding-project-pro-87744, A * Pathfinding pro graph?

    i would have to write function to communicate with your agent somehow?

    which scripts are the first place to intercept your code communicating with in-built Unity Navmesh system to utilize one from A* pathfinding?

    also I notice some strange behaviour, your mass benchmark sample will begin to get horrible performance after 3000 entities (with game object), after they all reach end point, HOWEVER, if I disable local avoidance, then disable collision, then re-enable local avoidance, and then collision, they will be grouped into their same colors, and performance is once again stable?

    very peculiar. but it is still none the less a nice asset, I think the issue is the numbers of local avoidance calculation spam in small region of path calculation/re-calculation.
     
  20. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    Only that main thread might need to wait jobs, apart that none.

    In project settings https://lukaschod.github.io/agents-navigation-docs/manual/settings.html Query capacity settings to 4-8 can greatly improve performance.
     
  21. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    So you would need to essentially write a layer in navigation package that would use A * Pathfinding pro graph. If you have ECS coding experience you can try it yourself, I want to do this myself at some point, but could not find time.
    Essentially, you will need to write your own varations of these systems that would use A* Pathfinding:
    - NavMeshPathSystem - for requesting path from entity
    - NavMeshSteeringSystem - that uses requested path to construct funnel. With funnel gets desired direction into EntityBody.Force.
    - NavMeshPositionSystem - that progresses path and keeps entity within navmesh bounds.
    For the reference you can look up the systems itself and copy execution order.

    Did you tried setting query capacity in project settings https://lukaschod.github.io/agents-navigation-docs/manual/settings.html (I found 4-8 good range)
     
    unitygnoob008 likes this.
  22. unitygnoob008

    unitygnoob008

    Joined:
    Sep 17, 2016
    Posts:
    229
    hey thanks for the response,

    just so you are aware, some of us would gladly pay for integration add-on (market place supports adding external addons as pre-requisite packages) for some official A* pathfinding pro integration support. Even if it just a boiler plate/tech demo for working concept to use as base for your own system.
     
  23. zb737472783

    zb737472783

    Joined:
    Nov 8, 2018
    Posts:
    2
    May I ask when it will be supported Nav Mesh Link?
     
  24. zb737472783

    zb737472783

    Joined:
    Nov 8, 2018
    Posts:
    2
    I need rigidbody AddForce, how can I temporarily disable the navigation component
     
  25. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    No ETA yet. In discord channel there is feature request.

    In hybrid workflow you can disable agent to disable whole navigation. In ECS removing agent body should be enough.
     
  26. elanguido

    elanguido

    Joined:
    Nov 24, 2012
    Posts:
    4
    Hi, I am using hybrid flow. When the AgentNavMeshPathing component is added and the AutoRepath check is checked, there is a bug that causes the agents to go crazy searching for paths, going around in circles on themselves. It happens only sometimes, not always, and seems to be random.

    Only unchecking the AutoRepath checkbox in the inspector and activating it again solves it. How could I do this from code? Is there any way?

    EDIT to provide more information, I have reproduced the problem and it occurs when the agent is in a position in which there are two possible paths with the same distance to reach the target. So, the agent chooses one, in the next repath it chooses the other, the first again... and it doesn't go away from there.

    I'm trying to change the EntityPath properties at runtime to prevent this from happening, or even create a new NavMeshPath but nothing seems to work, all changes are ignored.

    Could you provide an example on how to change the behavior of the agent at runtime?
     
    Last edited: Nov 6, 2023 at 1:44 PM
  27. Lukas_Ch

    Lukas_Ch

    Joined:
    Oct 12, 2014
    Posts:
    70
    Can you post this in my discord channel and DM repro project, I could take a look. I usually provide support via discord as I have automated way to verify users.