Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 castor · May 19, 2017 at 09:35 PM · navmeshnavmeshagentpathobstacle avoidance

Navmesh - How to calculate path AROUND NavmeshAgent Obstacle Radius?

alt text

I might be missing the obvious since this seems a bit strange of a behavior.

Let's say we have 2 agents, Agent A and Agent B, and both have a Obstacle Avoidance radius of 0.5.

Agent B is currently static, and Agent A wants to move towards the TargetPos as illustrated below (blue is the navmesh, the red circles represent the Object Avoidance radius for each agent): alt text

My problem is that Unity always Calculates the shortest route to the TargetPos (yellow path), and because of the Obstacle Avoidance, Agent A ends up stuck in the corner, unable to pass by Agent B.

What I would like instead, is something like the green path in the image, where the calculation takes into account Agent B Obstacle Avoidance cylinder and plans around it. Or, since I've realized the agent avoidance doesn't re-calculate the path but does a local avoidance (at least according to the navmesh debug display), to take the longer route through the left side of Agent B so Agent A doesn't get stuck in the edge. Is there a way to do it? Is it part of Unity's NavMesh system?

NOTE: When Agent B is not in a corner, the obstacle avoidance works, and Agent B goes around him. It's just in this situation, where going around means doing the LONGER distance, that he decides to go through the shortest path that he gets stuck.

NOTE2: It's not feasible to add a NavMesh Obstacle component to Agent B since that would mean that if any other agents wants to calculate a path towards him (or he needs to calculate a path to anywhere) they would return as invalid! NavMesh Obstacle component only makes sense for non-agent objects. (Even Unity gives me a warning when I add the NavMesh Obstacle to a GameObject with a NavMeshAgent)

stupidagent.gif (478.8 kB)
agentpath.jpg (85.1 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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Jakob_Unity · Jun 22, 2017 at 07:18 AM

I'd still go for carving if the agent is static for a longer time. You need to toggle between the Agent and the Obstacle components, though, as they cannot meaningfully be active at the same time.

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 castor · Jun 22, 2017 at 04:29 PM 0
Share

But that solution will create a whole new set of much worse problems... The static agent, when trying to figure out if there is a path to anywhere on the map, will always return false, unless I keep toggling the carving off everytime I want to just calculate a path. Even worse, any other agent (moving or not) that wants to know if they can reach the carved agent, will also always return false since there is never a valid path with the carved mesh. (That is why I assumed the agents have their own system without messing the actual navmesh)

avatar image
0

Answer by Kurt5 · Jul 12, 2017 at 08:01 AM

You could bake the navmesh at runtime and put a NavMesh Modifier on Agent B that has a high cost and is only active when Agent B is not moving.

https://docs.unity3d.com/Manual/class-NavMeshModifier.html

You could also try messing around with avoidancePredictionTime for the NavMesh

https://docs.unity3d.com/ScriptReference/AI.NavMesh-avoidancePredictionTime.html

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 castor · Oct 04, 2017 at 11:02 PM 0
Share

The navmesh modifier doesn't solve the issue if there are more agents and seems pretty expensive performance wise.

The avoidancePredictionTime doesn't make any difference, unfortunately.

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

70 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

NavMeshAgent-obstacle avoidance but permit agent to pass by each other. 1 Answer

Is there any way to make the vertical automatically-generated Mesh Links from the NavMesh bidirectional? 0 Answers

Way to ignore specific navmeshobstacles for specific navmeshagent when creating path? 0 Answers

Find closest target on NavMesh for many possible targets 0 Answers

Navmesh with destructible obstacles 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