Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

NavMesh dynamic avoidence

Discussion in 'Developer Preview Archive' started by Nic-Cusworth, Dec 25, 2011.

  1. Nic-Cusworth

    Nic-Cusworth

    Joined:
    Oct 12, 2008
    Posts:
    218
    I've been messing around with the new NavMesh features. In my scene I want to be able to drop un-moveable obstacles that the agent should dynamically path around. I worked out that all obstacles need to have the NavMeshAgent component but the agent can push them aside if they collide with them.

    How do I setup an obstacle that can't be pushed/moved by the agent. And wouldn't it be cheaper to have a NavMeshObstacle or something instead of static obstacles using the NavMeshAgent?

    Thanks in advance for any help.

    Nic.
     
  2. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Not really sure but did you try making the unmovable objects kinematic or maybe just playing around with there weight to make them damn heavy.
     
  3. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Currently there is not support for adding fully dynamic obstacles to the
    navigation system (other than NavMeshAgent) - but it is planned for a future
    release (and they will be cheaper than using agents).

    You current best options are:

    . Use physics on the object and agent - making the obstacle kinematic.
    (See the "door2" scnene in the NavMesh sample for the developer preview).

    Downsides: You're using the physics subsystem (mem./perf.) also - the agents
    can get trapped in a concave topology of the physics system.

    . If you know where the obstacles will fall - you can bake the navmesh having
    marked up the areas with a specific NavMeshLayer - and disable/enable that at
    runtime - by changing the walkableMask of the navmesh agents. (see the "bridge"
    scene of the NavMesh sample for the developer preview).

    Downsides: You may not know the position of the obstacles off-line. And you may
    run out of layers if you have a lot of obstacles

    Cheers..
    /Jakob
     
  4. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    If the non movable object has a rigidbody attached to it you could checkbox X, Y, Z Constraints on Transform and Rotation to freeze movement.
     
  5. Nic-Cusworth

    Nic-Cusworth

    Joined:
    Oct 12, 2008
    Posts:
    218
    Thank you all or the advice. I've ticked the Kinematic flag and they are staying in place now. It's good to hear that there's a cheaper solution being planned. I'm worried about performance on iOS using both a NavMeshAgent and a RigidBody on a lot of objects. I'll do some tests today.

    Thanks again!

    Nic.
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    works fine on ipad2 with a few going but the 3gs is a real worry, particularly as it's still sold by apple. That thing started to unbearably chug. And I hadn't even called any navmesh movement routines. Must investigate further.
     
  7. andorov

    andorov

    Joined:
    Feb 10, 2011
    Posts:
    1,061
    Just constantly override the agents .nextPosition with its current transform.position.

    Easy peasy.
     
  8. Nic-Cusworth

    Nic-Cusworth

    Joined:
    Oct 12, 2008
    Posts:
    218
    I've played around with this some more and come to the depressing conclusion that I can't use it. It really is a barebones implementation of NavMesh Pathfinding. It really needs to have proper colliders to allow for dynamic scenes. Tried all the suggestions here and the results are just too unpredictable.

    Adding rigidbody and kinematic does solve some of the problem of the objects not moving but the agent just tries to walk through them anyway. I'm also concerned about the reliance on the physics system to get this working. Haven't tested on iOS but I know that given the nature of the project, turning 100+ dumb path engine blockers into NavMeshAgents with RigidBody is not the smartest of moves.

    For an FYI, I've been using v2.92 of Aron Granberg's A* Pathfinding up until now with a hope that Unity's 3.5 built in would be a more integrated solution. I think I'm going to have to upgrade to 3.0 or find an alternative solution for now. The only issue I have with 2.92 is recalculating the grid at run time on a iOS device takes a number of seconds, but at least you can recalculate the grid/mesh.

    Wondering if there will be further development on the NavMesh tools for 3.5 launch because I definitely can't wait around for 3.6.

    Nic.
     
  9. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    @ Nic Cusworth.

    Sadly, I gotta agree with you here.

    On the positive side it's a GREAT integration of a simple navmesh system. Very easy to use. excellent integration with the unity environment.

    But on the negative side, it's very, very basic. It simply won't work for any game type that has any meaningful number of dynamic objects (RTS games, tower defense, some platformers, etc) You can't rebake the navmesh at runtime, you can't dynamically change an objects layer, etc.

    I do hope to see further improvements before 3.6. In the meantime, you're right, Nic. Aron's A* Pathfinding is a more flexible solution.

    Great first effort, but definitely room for improvement.
     
    Last edited: Dec 26, 2011
  10. 3dsquad

    3dsquad

    Joined:
    Sep 3, 2011
    Posts:
    65
    +1 for Aron's. The biggest advantage is being open-source, and generally more powerful.
     
  11. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    I don't know what exactly you want to do, is it something like this??
    All that wall has is a box collider, instead of expensive rigidBody+Agent components:


    Yes, it could be much better, I hope they implement better tools in the future.

    I'd used that too, but I like Unity's system, it automates a LOT of things and thats what I really care about;
    That kind of avoidance should be automatic generated too, but as they said it is not default behaviour so they just left it for us to do ourselves; Anyways that video is the same thing I've done with Aron's system, it is much cheaper than using dynamic path modifiers and runs super smoothly on my iPads. It just gets the normal direction of the collided face and rotates the moving character to avoid it, using raycast and distance calculations.
     
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    If you really care about 'does it on its own' you should upgrade to A* 3.x from the 2.x version as 3.x added recast (the same thing unity and rain {one} uses) to generate the nav mesh and it has different other things too.
    And its much to worlds easier to integrate unity steer with A* vs trying to get the untouchable 'world dominance' agents to work with it
     
  13. Nic-Cusworth

    Nic-Cusworth

    Joined:
    Oct 12, 2008
    Posts:
    218
    I went and purchased Simple Path to see if it does everything I need for the project. I was sold a while ago on the dynamic pathing but was holding out for Unity 3.5. Haven't had a lot of time to check it out but seems to lack the nice NavMesh/Grid generation of A* and Unity but seems to make up for it in simplicity. I can live without the grid generation by just placing invisible blockers in the scene I think.

    Nic.
     
  14. Nic-Cusworth

    Nic-Cusworth

    Joined:
    Oct 12, 2008
    Posts:
    218
    Thanks for giving an example. It's close but not exactly. Having the agent 'slide' around collision looks ugly. The Agent should know about the object in it's path and avoid. A better example are the Simple Path movies:

    http://youtu.be/h3jxh26hlyQ

    Nic
     
  15. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    What is the roadmap of v3.6? (I knew there will be v3.5 only)
     
  16. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    There has not been any mention that there will be a 3.6, so hard to say whats planned for then.
     
  17. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    Hey, just before i write this on my own, does there exist a flee/hide behaviour/script for agents already?
     
  18. Wahooney

    Wahooney

    Joined:
    Mar 8, 2010
    Posts:
    281
    I must agree with the general sentiment, the introduction of NavMeshes is great as a simple solution, but as soon as I try to have something slightly more involved than guys running in rooms, ie. agents running on walls/roofs, agents that use special moves like crouhing or duck-jumping, dynamic obstacles, etc. I'm left wanting.

    Things I'd personally like to see in future releases are:
    - the aforementioned navigation on roofs/walls
    - user defined path hinting (crouch to get through here)
    - multiple nav meshes: tall monster navmesh (can't fit through regular doors), short monster nav mesh (can run through smaller holes in walls), average human nav mesh, wall climber nav mesh, etc. This could even be achieved by having per layer Bake settings.

    Not sure if any of the above points are currently possible through some voodoo or something, but initial investigations say no.
     
  19. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
  20. Lypheus

    Lypheus

    Joined:
    Apr 16, 2010
    Posts:
    664
    Ok got it, finding that my doors need to have Interpolate/Continuous Dynamic enabled or the mob just forces itself through the collider.
     
    Last edited: Apr 20, 2012