Search Unity

Navmesh obstacle carving - problem with agents

Discussion in 'Scripting' started by RenderSystemStudio, Nov 25, 2013.

  1. RenderSystemStudio

    RenderSystemStudio

    Joined:
    May 16, 2013
    Posts:
    37
    Hi all!

    I have a big problem. I use navmesh pathfinding. I have some enemy units with navmesh agent.
    If is enemy unit standing, this unit has enabled navmesh obstacle with carving. Other units move around this. Problem is here:
    Some of other navmesh agents don`t move(are stopped) , if I disable carving all works OK.

    How solve this problem please?

    Thank you for any ideas!

    Sorry for my EN ;)
     
  2. lynchemall

    lynchemall

    Joined:
    Nov 29, 2012
    Posts:
    3
    I'm running into the same problem. The autoRepath doesn't work in some circumstances. Every time you carve you seem to risk a certain number of agents getting stuck. Carving again frees some but blocks others. I'm trying to turn off the autoRepath and do it myself but no joy sofar. Have you made any progress?
     
  3. Dan Deibler

    Dan Deibler

    Joined:
    Mar 13, 2013
    Posts:
    16
    Has anyone found a solution to this bug? Was it fixed with 4.3.3? The changelog lists a few NavMesh bug fixes, but not this specific bug. I'm trying to figure out if I need to start the paperwork for the lengthy process of getting the update installed on our machines.
     
  4. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    I gave up on using the carving on Navmesh obstacles, it seems they are changing the navigation mesh all the time, but fps drops from 60fps to 30fps just by the simple fact of adding a carved obstacle in the scene.
    And yes, the distance to recalculate is big.

    Also navmesh agents when I send them to move somewhere (around 40 navmesh agents), unity now crashes, while in 4.2 everything worked ok.
     
  5. Dan Deibler

    Dan Deibler

    Joined:
    Mar 13, 2013
    Posts:
    16
    It sounds like you're experiencing a related, but possibly slightly different bug I've noticed. In 4.3, the "Move Threshold" setting on NavMeshObstacle seems to be completely broken; it doesn't appear to have any effect at all. The nature of the FPS drop indicates that the obstacle is constantly carving the mesh, regardless of how much it has moved and regardless of the "Move Threshold" setting. It does appear (based on FPS) to not re-carve if the obstacle stays in exactly the same position, but if there is any change in position, no matter how small, it does seem to be re-carving. We got our team updated to 4.3.4 and it appears to still be broken. I think I'll put in a bug report and start a thread about that issue, because not being able to prevent it from recalculating the navmesh carving every single frame without giving up the ability to carve at all is completely breaking our game. The performance hit for recalculating the mesh carving every frame makes it borderline unplayable.
     
  6. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
    yup, I gave up on the carving, the fps hit was just too big.
    Please do submit a bug report, I already submitted one regarding the crashes that now happen when we try to move about 40 agents at the same time, this was not a problem before.

    Are you experiencing crashes with navagents ?
     
  7. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    It would be great if you can submit a bug reporter with a project folder of low performance when carving.

    Also if agents are not auto-repathing. Please make a reprocase and log a bug.
     
  8. BigB

    BigB

    Joined:
    Oct 16, 2008
    Posts:
    672
  9. Shinugami

    Shinugami

    Joined:
    Oct 17, 2012
    Posts:
    54
    Thanks for this thread; I found it very helpful. I also have the same problem where the Auto-Carving causes AI to get stuck. The downtime until an AI resumes movement seems far too long. Despite using Unity Pro I was almost about to totally remove the NavMesh navigation from my game; until I saw that, presently, objects with rigidbody components have a bug when dealing with carving. I'll work on other aspects of the game for now and if required later I will change the movement to something else; if the bug isn't fixed in the next version.
     
  10. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Are you talking about problem like this?

     
    Daftolddad likes this.
  11. JibberJabber

    JibberJabber

    Joined:
    Apr 4, 2013
    Posts:
    7
    Gua - we are having that exact problem. Also, if there is a single carving navMeshObstacle in the scene then a lot of our AI agents (with rigidBodies) are simply walking through ordinary collider objects (doors etc.).
     
  12. IPnose

    IPnose

    Joined:
    Jun 6, 2014
    Posts:
    20
    I have exactly the same problem. Is anyone found a solution?
     
  13. ryte2byte

    ryte2byte

    Joined:
    Jan 28, 2014
    Posts:
    2
    Having this exact same problem with Unity 5. 1 navmesh agent simply refuses to move if there are ANY navmesh obstacles in the scene with carving enabled and there are 4 or more agents in the scene.
     
    Last edited: Mar 12, 2015
  14. psilord

    psilord

    Joined:
    Feb 13, 2015
    Posts:
    3
    Using Unity 4.6.5f1, I've run into a very similar problem. In my case, an agent is outside of a room and trying to path find into the room. If I "lock" the door by having it carve the nav mesh when shut, the agent halts, goes into the PathFinding state, and never leaves it, even when I change the destination to somewhere it can reach! Only by "unlocking" the door, causing (the original) valid path to be in existence again, does the agent start going to where ever its _new_ destination was set. This is quite thoroughly frustrating.
     
  15. joaodeconto

    joaodeconto

    Joined:
    Apr 16, 2012
    Posts:
    4
    The best workaround I've found until now, is to check for isPathStale on AI update or create an event for carving notifications. Everytime you carve or move a carved object, it will stale some paths, which need to be recalculated. The autorepath doesn't seems to work, so using something like the code below, might be usefull. Another cause for massive agent freeze, is to set a destination.position out of the navmesh bounds, so check for partial paths and find a suitable point to calculate it.
    Code (CSharp):
    1. if(NavAgent.isPathStale)
    2.                 {
    3.                         if (NavAgent.pathStatus != NavMeshPathStatus.PathComplete)
    4.                     {                      
    5.                         if (NavAgent.pathStatus != NavMeshPathStatus.PathInvalid)
    6.                         {
    7.                             Vector3 randomVector = Random.onUnitSphere;
    8.                             Vector3 position = PathfindTarget - randomVector;
    9.                             position.y = PathfindTarget.y;
    10.                             NavMeshHit hit;
    11.                             if(NavMesh.SamplePosition(position,out hit,1,1))
    12.                             {
    13.                                 Move (position);
    14.                             }
    15.                             else Move(transform.position) //reset move
    16.                         }
    17.                         else
    18.                         {
    19.                             Move (PathfindTarget);
    20.                         }
    21.                     }                  
    22.                 }
     
  16. barbe63

    barbe63

    Joined:
    Oct 6, 2014
    Posts:
    35
    Please i'm having the same issue. I don't even carve when objects are moved but it's enough to mess everything. Look at this, if I remove carving everything works fine but when it's enabled the NPC can't find a way in the purple zone when it goes next to the door with obstacles. It's just stuck running...

    carveIssue.jpg
     
  17. weitay

    weitay

    Joined:
    Aug 5, 2012
    Posts:
    10
    Problem still persists with Unity 5.4 in 2016
     
  18. mjunaidch

    mjunaidch

    Joined:
    Oct 23, 2016
    Posts:
    7
    This problem still persists with 5.6.3... any body have solution for this.. I have 1 nav mesh obstacle on my player with carving On when player is moving then all nav mesh agent stop moving...I have to carving On because I don't want other nav mesh agent is passing in player....Can anybody Help me ??
     
  19. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    With Unity 2018 usintg dynamic carving makes the enemies go crazy moving to random places and also jitter a lot like if the enemy was being shaked very fast instead going to the player as its programmed and as it does when carving is not enabled. Also when using navmesh obstacles in moving enemies makes them move animations much faster, i also in reduced spaces they move slower dont know why, using navmesh obstacles makes everything stop working as it should
     
  20. Capella34

    Capella34

    Joined:
    Mar 19, 2013
    Posts:
    2
    Issue still persists in Unity 2017.4.9f1. I am having this exact same issue in my game. I run about 10-20 AI units at the same time and every time a NavMeshObstacle is added to the scene (which uses Carving), all of the units rotate for a second and then resume their path and a half of them just get stuck walking into NavMeshObstacles altogether.

    Valve pls fix
     
    famtosha likes this.
  21. ArchAngel075

    ArchAngel075

    Joined:
    Jul 12, 2015
    Posts:
    2
    I ran into a issue where carving enabled on runtime created obstacles caused all my agents to freeze.
    Using the new runtime navmesh scripts.

    A solution i use is to use a volume modifier that overrides the area with a non-walkable area on my stationary objects i create at runtime and removing navmesh obstacle component.
    Ofcourse this wont be viable for non-stationary objects.
     
  22. Cosmono

    Cosmono

    Joined:
    Nov 6, 2018
    Posts:
    2
    omg, I can't believe this is still happening here in May 2019. Either I am checking the archived thread or Unity hasn't worked on it at all. But agents "go insanely crazy" when there is a "carve" function for dynamic NavMesh obstacles, this is too much for me. I literally wasted my whole day trying to figure it out but ended up in vain.
     
    markusroh likes this.
  23. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    I am using Unity 2019.2 and carving stationary still fails, agents when spawn jump to another position just when obstacles are set to carving, if there are no obstacles or they are with no carving doesnt happen
     
    gilbertoPlayX likes this.
  24. gilbertoPlayX

    gilbertoPlayX

    Joined:
    Sep 23, 2019
    Posts:
    7
    i'm also having problems on unity 2019.2
     
  25. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    having same issue..
     
  26. hnngaf

    hnngaf

    Joined:
    Sep 10, 2019
    Posts:
    3
    Same issue on 2019.3.4f. I have an agent spawning in the same frame as some nav mesh obstacles. The agent is magically moved to 0,0,0. If I remove some of the obstacles so not so much nav mesh carving is required, the agent stays where I spawned it. In the original scenario I can see the agent for 1 frame in the correct position before being moved to 0, at the same time as the new nav mesh holes appear. It seems like the nav mesh is either not available or gives out garbage results for sample queries during larger carve operations.
     
  27. zoomyjs

    zoomyjs

    Joined:
    Jan 16, 2016
    Posts:
    5
    I have same problem. No matter what parameters of navmesh or navmeshagent the navmesh instantly shoots the character to the start.
     
  28. zoomyjs

    zoomyjs

    Joined:
    Jan 16, 2016
    Posts:
    5
    Just found a solution. Instantiating the object as disabled and immediately enabling it fixed it and now stays on navmesh
     
    Tudor_n likes this.
  29. Tudor_n

    Tudor_n

    Joined:
    Dec 10, 2009
    Posts:
    359
    This still happens in 2020.1, albeit, closer to what the original posters posted. A dynamic carver will have agent paths invalidated. Weirdly, it only invalidates paths that are more than X units away.

    The workaround above does NOT solve the issue. Simplified project submitted with the bug report.

    Update, this was because of large instant rotations ( think reversing forward every frame ). This triggered constant navmesh rebuilds which kept invalidating (longer) paths. Why only the longer paths? No clue, really but I assume the idea is the odds of them being invalidated by a navmesh change is higher than shorter paths.
     
    Last edited: Aug 16, 2020
  30. tangbiao1

    tangbiao1

    Joined:
    Mar 23, 2021
    Posts:
    1
    It is still exists...
     
  31. doubleu_kskim

    doubleu_kskim

    Joined:
    Apr 1, 2015
    Posts:
    1
    Use SetDestination instead of SetPath.
     
  32. GameDeveloperAf

    GameDeveloperAf

    Joined:
    Jul 3, 2020
    Posts:
    71
    The issue is that the Navmesh Obstacle is not developed fully. When so many agents with carve obstacles area size goes into each others and can not find the next target because of the carve. This is issue, but not fixed.
     
  33. WoodsmanThePeasant

    WoodsmanThePeasant

    Joined:
    Jun 2, 2013
    Posts:
    7
    I had a similar issue. When enemies clumped up around the player, the back ones would push the front ones forward, making them move, and in turn deactivating their carved circle on the navmesh because they were moving and only stationary is check.
    My solution to this was in playing with the actual values of the NavMeshObstacle parameters on each enemy. Specifically "Time To Stationary" and secondly, "Move Threshold". Here are my values (see thumbnail)
    Here they are in text:

    Move Threshold: 0.1
    Time To Stationary: 0.02

    I noticed that if you move Time To Stationary down to 0.01, then as the enemies draw closer together, their "nav mesh holes" kick on even though they are not stationary. For me the issue was that if I unticked the "Carve Only Stationary" then the the "nav mesh holes" would be on but the enemy couldn't move. On the other hand, if "Carve Only Stationary" was off, then they would clump up and move eachother thusly preventing the enemy from ever being stationary to turn the hole on. I know that was a lot haha. My point is this. If you want your enemies to have the "nav mesh hole" always on, but also want to leave the "Carve only Stationary" checked (which you have to do in order for them to move), the key is to move the "Time To Stationary" parameter down to an unreasonably low level like 0.01. I hope this helps someone out there who gets to the bottom of the thread and never gave up.
     

    Attached Files: