• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Astraeus · Feb 10, 2013 at 05:14 PM · c#ainavmesh

Getting NavMeshAgents to avoid obstacles effectively

I'm making a tower defense that uses a navmesh for AI movement. I want the player to be able to place objects down and have the AI avoid them. Right now, the NavMeshObstacle doesn't really do much besides stopping the AI from running into it. So basically I have a problem where is there is a cone of obstacles, the AI will run straight into it and stay there. alt text

This is my crude drawing of what is happening. The AI starts at the green and runs into the black obstacles along the black path, stopping at the red point. I want it to be able to follow the green lines instead of getting stuck there. This also happens when the obstacles are overlapping, so it tries to get through even with no space at all.

Is there a way to get the AI to actually avoid the obstacles instead of running into them?

untitled.png (6.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Feb 10, 2013 at 05:26 PM

Unfortunately Unity's Navmesh doesn't update dynamically. What you actually want is that dynamic obstacles are included in the pathfinding itself. However this doesn't work. Unity only has a very simple "avoidance" behaviour which will try to slightly go left or right to avoid the obstacle, however if the calculated path goes straight through a group of obstacles it fails totally.

I heven't used it myself but a workmate has used Unity's Navemesh and come across the same problem. Our solution was to use a third party Navmesh framework which allows even recreation of the Navmesh at runtime as well as dynamically updating the Navmesh. The framework isn't as optimised as Unity's when it comes to simplify the navmesh. It just uses a grid mesh and executes an A* pathfinder on it. But the project target is mobile (iPad, Android) and it seems to work pretty well.

Unfortunately i can't remember where we found it, but as far as i remember it was actually an opensource framework.

A quick google gives me this and this but i guess there are a lot others out there. I think we used the one in the second link, but i don't used it myself, so i'm not sure ;)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Astraeus · Feb 10, 2013 at 05:32 PM 0
Share

Thanks, I'll take a look at what you found

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

NavMesh link does not connect properly on runtime 1 Answer

Distribute terrain in zones 3 Answers

My ai is getting stuck when there is a lot of them 0 Answers

How to get a velocity unit vector from a NavMeshAgent? 1 Answer

Need help detecting barriers for my game 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges