Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 DJICS · Jun 29, 2015 at 01:18 PM · navmeshtower-defense

Not allow instantiate obstacle that make destination unreachable

Hi all !

In the case of a tower-defense game using navmesh (with tiled floor), is it possible to detect if the construction of a tower will make the destination unreachable ?

I tried to instantiate an invisible obstacle on the tile on which my mouse was over and print "blocked" if the path become partial and it work but, the navmeshagent goes wierd during that... Is there another way that I didn't found ?

Thanks in advance !

Comment
Add comment · Show 4
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 AlwaysSunny · Jun 29, 2015 at 01:18 PM 0
Share

Someone correct me if I'm wrong, but I think Unity's native navmesh pathfinding system is ill-suited to such a task. In my investigation some year(s) ago when the feature was introduced, I was given the impression that dynamic obstacles had some substantial limitations. At least, I recall rejecting it for my project at the time because dynamic obstacles were a key feature and I didn't like the way they were handled.

In any case, the only procedure I am aware of for verifying path walkability is a brute-force test. I do this at load time for my generated maps (different project altogether), but I'm using classic a-star, not Unity's navigation system. $$anonymous$$ethinks the principle would be the same, though. Pick every point from which an agent can start, and try to get a path to every point the agent can end. If any of these attempts to get a path fails, you have blocked an essential corridor and created an unwalkable scenario.

What further assistance do you require?

avatar image DJICS · Jun 29, 2015 at 01:45 PM 0
Share

Thanks for your reply !

Sure, it's probably easier to use a proper A* script. But I don't really understand how to use a "brute-force test" on my case... Do you mean that I have to instantiate an invisible obstacle each time my mouse is over a tile, recalculate the path and if it's blocked, destroy that obstacle, declare that tile "unbuildable" and finally recalculate another path for agents to resume on it?

Wouldn't that drop performance a lot ?

avatar image AlwaysSunny · Jun 29, 2015 at 03:08 PM 1
Share

"Do you mean that I have to instantiate an invisible obstacle each time my mouse is over a tile, recalculate the path and if it's blocked, destroy that obstacle, declare that tile unbuildable..."

Yes, that is my suggestion. From every entry point, calculate a path to every goal point. If any of these paths cannot be found, it means the obstacle you are previewing would create an "island" in your nav mesh.

"Wouldn't that drop performance a lot?"

It's certainly something you should do as little as possible. Only once per previewed obstacle. If you discover performance is suffering, you could perhaps distribute the work over several frames using a coroutine and yield statements between checks. Simply disallow any decision-making during the check procedure.

avatar image DJICS · Jun 29, 2015 at 05:36 PM 0
Share

Wow ! That worked like a charm ! Thanks a lot for the concept ;)

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to make NavMeshAgents traverse two possible paths 1 Answer

How do you rotate a NavMesh object to match the terrain's angle? 1 Answer

Question on Setting/Building Navmesh / Navmesh Agent Path 0 Answers

Navmesh Agent With Physics? 1 Answer

NavMesh Agent not updating (Setting) new path 1 Answer


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