• 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 SovietAlex · Apr 18, 2018 at 10:01 PM · navmeshnavmeshagentnavigationobstacleobstacle avoidance

Unity NavMesh obstacle avoidance?

So, I calculate the path to the target. The target can move around so the path is always changing. The Object avoids obstacles like it should and everything works fine. But, when you can't calculate a path because there is no way to reach the target, weird stuff happens. So, I just say

  if (m_Agent.pathPending)
     {
              transform.position = Vector3.MoveTowards(transform.position, m_Target.transform.position, m_MoveSpeed * Time.deltaTime);
 
         transform.LookAt(new Vector3(m_Target.transform.position.x, transform.position.y, m_Target.transform.position.z));
     }

But this doesn't avoid obstacles.

So any ideas?

Comment
Add comment · Show 2
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 Serinx · Apr 19, 2018 at 02:24 AM 0
Share

In my experience with Navmesh, it doesn't like the agents to be manually moved.

Have you tried setting Nav$$anonymous$$eshAgent.autoRepath to true if it isn't already?

Why can't you calculate a path? Are there dynamic obstacles in the way?

avatar image SovietAlex Serinx · Apr 19, 2018 at 06:39 PM 0
Share

Ya I tried that it didn't work. Imagine there is a square frame and you are inside it. I can't reach you so how do I still avoid some obstacles to get to the frame but when I get to the frame, I want to just keep moving towards the target. Like a zombie that doesn't understand how to get to the target.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

82 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 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

Trouble with Navmesh Agent and Navmesh Obstacle 0 Answers

Toggling NavMeshAgent and NavMeshObstacle 2 Answers

Navmesh carving causing issues upon enabling navmesh agent component 0 Answers

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

NavmeshAgent and NavmeshObstacle and Bake don't work with AICar 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges