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

Is this as good as NavMeshAgent AI gets out of the box?

Discussion in 'Scripting' started by BadSeedProductions, Aug 29, 2019.

?

What's better for intermediate pathfinding?

Poll closed Feb 29, 2020.
  1. Unity AI

    50.0%
  2. Custom AI

    50.0%
  1. BadSeedProductions

    BadSeedProductions

    Joined:
    Dec 26, 2014
    Posts:
    144
    I've used navmesh a couple of times in tutorials and I was able to start exploiting the object avoidance right off the bat. Basically I've noticed that if you put an obstacle perfectly in between you and the navmeshagent (even if you put a navmeshobstacle script on the obstacle) the navmeshagent's head spins in circles and sparks start flying out of it's ears... Ok so not that dramatic, but it is obviously seriously confused. It stops, wiggles, strafes (not programmed to strafe) and then eventually in very slow motion it will sort of strafe around the obstacle and get past. If there is a second obstacle, no chance, it just sits there. I can't understand why it can't find a path around the obstacles, just to be clear, in my test project there is a very large open navmesh, with no small paths... so the paths possible are countless. I've changed obstacle avoidance quality to High, same results (I actually couldn't get the Low quality and High quality nav mesh agents to act any differently). Is this the best it gets out of the box or am I missing something? I feel like I could program a better AI in 15 minutes with raycasts, but before I go that route I just wanted to make sure that I'm not just overlooking something or misunderstanding something. All results I can find online include adding scripts to supplement the AI's intelligence (or lack thereof) to solve these sorts of issues. For example, if navmesh agent has not moved in x seconds, change target temporarily to see if that can get them unstuck.

    I am using Unity 2018
     
  2. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    493
    It's the first time I'm hearing about this issue. Might sounds pretty obvious, but are you sure that you baked the navmesh after placing the object?
     
  3. BadSeedProductions

    BadSeedProductions

    Joined:
    Dec 26, 2014
    Posts:
    144
    I baked the navmesh onto the plain (ground) but I did not bake obstacles. Specifically in my game the objects that need obstacle avoidance are not static so I didn't bake any obstacles on the navmesh. The obstacles for my case need to be dynamic so I gave my test objects a NavMeshObstacle component
     
    Last edited: Aug 29, 2019
  4. Another useless poll with no real meaning.

    Whatever you can make work. Every tool is as good as you can utilize. If you don't feel comfortable with the built-in navmesh + pathfinding, look for something you can be comfortable with and you can make it work. Also it depends what kind of AI solution you intend to use. Some are working great with the built-in navmesh and basically rely on it, some does not. People won't be able to meaningfully answer your question unless they get to know your project like you do.
    So the best advice you can get is use whatever makes sense for you both for your level of understanding of things, your comfort-level with certain tools and other tools you're planning to use.
     
  5. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
    Did you set the NavMeshObstacle to carve? I've used NavMesh extensively and only encountered the problem you describe when things aren't set up correctly.

    I agree!
     
  6. BadSeedProductions

    BadSeedProductions

    Joined:
    Dec 26, 2014
    Posts:
    144
    Another useless reply with no real meaning...

    Carve basically puts a hole in the navmesh, which is great for objects that don't move... However I observe the same behavior with carve even if my obstacle isn't moving.

    I think this can basically be summed up to The navmesh needs extra scripting to make a meaningful pathfinder, I don't think I'm missing anything
     
    Last edited: Aug 30, 2019
  7. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
    As NavMesh doesn't reproduce this problem for me, even with moving NavMeshObstacles I can only assume that you are in fact missing something, and not just good manners.

    As far as I'm concerned you're on your own now.